Blogger Information
Blog 18
fans 0
comment 2
visits 8726
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
表单、iframe后台、元素样式来源优先级
弦知音的博客
Original
361 people have browsed it

表单、iframe、元素样式来源优先级

1.表单

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>会员注册表</title>
  8. </head>
  9. <body>
  10. <h3>会员注册表</h3>
  11. <form action="" method="post">
  12. <!-- 帐号 -->
  13. <label for="my-name">账号:</label>
  14. <input type="text" id="my-name" name="my-name" placeholder="请输入您的账号" autofocus required><br>
  15. <!-- 邮箱 -->
  16. <label for="my-email">邮箱:</label>
  17. <input type="email" id="my-email" name="my-email" placeholder="请输入您的邮箱" required><br>
  18. <!-- 密码 -->
  19. <label for="my-pwd">密码:</label>
  20. <input type="password" name="my-pwd" id="my-pwd" placeholder="请输入您的密码" required><br>
  21. <!-- 性别 -->
  22. <label for="male">性别:</label>
  23. <input type="radio" name="my-gender" id="male" checked><label for="male"></label>&nbsp;
  24. <input type="radio" name="my-gender" id="female"><label for="female"></label><br>
  25. <!-- 爱好 -->
  26. <!--! for 如何关联多个id -->
  27. <label for="game">爱好</label>
  28. <input type="checkbox" name="my-hobbies[]" id="game" checked><label for="game">游戏</label>
  29. <input type="checkbox" name="my-hobbies[]" id="swim" checked><label for="game">游泳</label></label>
  30. <input type="checkbox" name="my-hobbies[]" id="ball"><label for="game">打球</label><br>
  31. <!-- 会员级别 -->
  32. <label for="my-level">级别</label>
  33. <select name="my-level" id="my-email">
  34. <option value="1">黑铁</option>
  35. <option value="2" selected>黄铜</option>
  36. <option value="3">白银</option>
  37. <option value="4">黄金</option>
  38. </select><br>
  39. <!-- 简介 -->
  40. <label for="my-brief">简介:</label>
  41. <textarea name="my-brief" id="my-brief" cols="30" rows="10" placeholder="请简单的描述介绍一下您"></textarea>
  42. <div><button>注册</button></div>
  43. </form>
  44. </body>
  45. </html>

请问,label标签的for元素怎么关联多个id,如上例默认复选项默认2个的情况下,如何做到1个for元素关联多个id?

2.iframe后台

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>后台框架</title>
  8. </head>
  9. <style>
  10. h3{
  11. background-color: aqua;
  12. height: 200px;
  13. overflow: hidden;
  14. }
  15. ul, iframe{
  16. float: left;
  17. }
  18. ul{
  19. width: 200px;
  20. background-color: rgb(42, 177, 71);
  21. }
  22. li{
  23. list-style: none;
  24. }
  25. iframe{
  26. border: 1px solid #000;
  27. width: 300px;
  28. height: 200px;
  29. }
  30. </style>
  31. <body>
  32. <!-- !注意:在label标签for属性关联的是目标的id,在使用iframe时,却是target的值与iframe里name的值对应 -->
  33. <h3>后台管理系统</h3>
  34. <hr>
  35. <ul>
  36. <li><a href="https://www.csdn.net/" target="my-backstage">CSDN</a></li>
  37. <li><a href="https://www.163.com/" target="my-backstage">163</a></li>
  38. <li><a href="https://www.sina.com.cn/" target="my-backstage">Sina</a></li>
  39. </ul>
  40. <!-- 后台主体内容显示界面 -->
  41. <iframe src="" frameborder="0" name="my-backstage"></iframe>
  42. </body>
  43. </html>

注意:在label标签for属性关联的是目标的id,在使用iframe时,却是target的值与iframename的值对应

3.元素样式来源与优先级

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>样式来源与优先级</title>
  8. </head>
  9. <body>
  10. <!-- 默认样式,继承自html -->
  11. <h1>我是中国人,我爱自己的祖国</h1>
  12. <!-- 自定义样式,行内样式 style属性 -->
  13. <h2 style="color: blue;">我的一小步,人类的一大步</h2>
  14. <!-- 自定义样式,行内样式 style ,h3内容文字颜色为green -->
  15. <div style="color: red;">
  16. <h3 style="color: green;">Hello World</h3>
  17. </div>
  18. <!-- 同名样式后面的覆盖前面的 -->
  19. <style>
  20. h4{
  21. color: lightgreen; /*被后面color的样式覆盖*/
  22. color: lightcoral;
  23. }
  24. </style>
  25. <h4>一屋不扫,何以扫天下</h4>
  26. <!-- 外部样式 -->
  27. <style>
  28. @import url('https://www.php.cn/static/layui/css/layui.css');
  29. </style>
  30. <h5>天下兴亡,匹夫有责</h5>
  31. </body>
  32. </html>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:提交代码时附带上 图例,便于理解和记忆
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post