Blogger Information
Blog 10
fans 0
comment 0
visits 5562
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0322作业
手机用户1615433136
Original
565 people have browsed it

实例演示选择器的优先级,id>class>tag

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  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. <style>
  9. /* id选择器,优先级大于class */
  10. #first {
  11. color: lightblue;
  12. }
  13. /* 类样式 ,高于标签*/
  14. .active {
  15. color: grey;
  16. }
  17. h1 {
  18. color: greenyellow;
  19. }
  20. /* id > class >tag */
  21. </style>
  22. </head>
  23. <body>
  24. <h1 class="active" id="first">柒合尚科技</h1>
  25. </body>
  26. </html>

<hr/>

实例演示前端组件样式模块化的原理与实现

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  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. <link rel="stylesheet" href="css/index.css" />
  8. <title>模块化样式表</title>
  9. <!-- <style>
  10. @import url(css/index.css);
  11. </style> -->
  12. </head>
  13. <body>
  14. <header>页眉</header>
  15. <main>主体</main>
  16. <footer>页脚</footer>
  17. </body>
  18. </html>

外部css引入方式indx.css

  1. @import url(header.css);
  2. @import url(main.css);
  3. @import url(footer.css);

实例演示常用伪类选择器的使用方式,并用伪类来模块化元素组件

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  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. <style>
  9. @import url(css/menu.css);
  10. /* 只要获取到页面中某个元素组件的入口,再根据子元素的位置,使用伪类就可以选择任何一个元素 */
  11. </style>
  12. </head>
  13. <body>
  14. <nav class="menu">
  15. <a href="">首页</a>
  16. <a href="">视频</a>
  17. <a href="">下载</a>
  18. <a href="">注册/登陆</a>
  19. </nav>
  20. <hr />
  21. <form action="" style="display: grid; gap: irem" class="login">
  22. <input type="text" placeholder="UserName" />
  23. <input type="password" placeholder="password" />
  24. <input type="email" placeholder="demo@email.com" />
  25. <button>提交</button>
  26. </form>
  27. </body>
  28. </html>

menu.css

  1. .menu :first-of-type {
  2. background-color: lightgreen;
  3. }
  4. .menu :last-of-type {
  5. background-color: lightseagreen;
  6. }
  7. .login :only-of-type {
  8. background-color: lightslategrey;
  9. color: white;
  10. }
Correcting teacher:天蓬老师天蓬老师

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