ios5固件,源头产地市场,半裸江山书包
.class
选择器要高于标签选择器。#id
选择器要高于.class
选择器。!important
的属性它的权重值优先级最高的,大于所有的选择器。.class
选择器谁的优先级高实践,实践内容如:将html
页面中的h2
标签设置文本颜色。代码块
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>优先级</title> <style> h2{ color: red; /*红色*/ } .box{ color: springgreen; /*绿色*/ } </style> </head> <body> <h2 class="box">微笑是最初的信仰</h2> </body> </html>
结果图
.class
选择器和id
选择器谁的优先级高实践,实践内容如:将html
页面中的h2
标签设置文本颜色。代码块
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>优先级</title> <style> h2{ color: red; /*红色*/ } .box{ color: springgreen; /*绿色*/ } #box{ color:blue; /*蓝色*/ } </style> </head> <body> <h2 class="box" id="box">微笑是最初的信仰</h2> </body> </html>
结果图
!important
属性呢,谁的优先级更高呢?color: red !important; /*红色*/
注意:
属性:值 !important
属性值用空格隔开即可。
!important
属性使用实践,看看!important
属性威力有多大哈。代码块
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>!important使用</title> <style> h2{ color: red !important; /*红色*/ } .box{ color: springgreen; /*绿色*/ } #box{ color:blue; /*蓝色*/ } </style> </head> <body> <h2 class="box" id="box">微笑是最初的信仰</h2> </body> </html>
结果图
.class
选择器、#id
选择器、!important
属性
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
css3 flex布局 justify-content:space-between 最后一行左对齐
网友评论