css 之标签
名称(选择器)
| 表示方式 |
标签 | |
id/ class | #(.) |
子 | > |
后代(子和孙) | 空格 |
并集 | , |
序列选择器 | first-of-type, |
属性重构:(并集选择器)
<html>
<head>
<style>
.clo1{
color: red;
}
.clo2{
color: red;
}
.clo1,clo2{
color: red;
}
</style>
</head>
<body>
<p class="clo1"></p>
<p class="clo2"></p>
<p class="clo3"></p>
<p class="clo4"></p>
</body>
</html>
序列选择器 nth-of-type()
同级别(x) | 同类型 | |
: | first-child | first-of-type |
: | last-chlid | last-of-type |
: | nth-child() | nth-of-type() |
: | ||
: |
属性选择器: 使用条件/格式 value 是否要用“”
class 不适用因为大部分 class 有多个值
条件 | 格式 |
标签元素[atts=value] | |
input |
属性选择器 re : 标签元素[atts=value]
[atts^=value] | |
[atts=value] | |
[atts=value] |