选择器
优先级
id>class>标签名
标签选择器 标签名为判定条件
li{
background-color: #D0D0D0;
}
class类选择器 class属性作为判定条件
class之间的优先级看定义先后
.pec{background-color: red;}
.grey{
background-color: darkgrey;
font-family: "宋体";
}
.yellow{
background-color: yellow;
font-family: "楷体";
}
id选择器 id属性为判定条件
只能用一次 id属性是为了划分页面结构 不能重复
#first{color: red;}
属性选择器
[align]{ box-shadow: 0 0 5px black; }
并集选择器 多个条件 或者关系
选择器1,选择器2 相当于if中的或者
* */
h2,h1,.red{
color: red;
}
交集选择器 多个条件递进 并且关系
选择器1选择器2
最多一个标签选择器,若出现必须写在最前面
* */
div.green{
color: green;
}
后代选择器 将html的结构体现在选择器中
选择器父 选择器子
* */
div a{
color: red;
}
伪类选择器:
a{color: grey;}
/a在悬停的时候才满足条件/
a:hover{color: green;}
a:active{color: red;}