Blogger Information
Blog 5
fans 0
comment 0
visits 2777
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
css优先级
帝踏锋
Original
512 people have browsed it

css的样式来源

  1. 外部样式通过标签link引入
  2. 当前文档,写在<style>中的样式
  3. 行内样式,通过属性style=""添加的
  4. 用户代理样式,浏览器默认样式

代码:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>css样式来源</title>
  7. <link rel="stylesheet" href="style.css"><!-- 1.连接外部样式 -->
  8. </head>
  9. <!-- 2.当前文档样式 -->
  10. <style>
  11. div{
  12. background:aqua;
  13. width:500px;
  14. height:500px;
  15. }
  16. </style>
  17. <body>
  18. <div>
  19. <h1 style="background:brown">666</h1><!-- 3.行内样式通过style属性添加 -->
  20. <!-- 4.浏览器默认样式'a'标签,蓝色字体有下划线 -->
  21. <a href="">a标签的默认样式是蓝色的字体有下划线</a>
  22. </div>
  23. </body>
  24. </html>

css样式优先级样式的解决方案

1.细化选择

  1. .style{background:red}

2.提高样式优先级

  1. {background:aqua !improtant;}
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
  • 2020-10-13 14:19:17