您现在的位置:首页 >> 前端 >> 内容

css3选择器

时间:2017/3/4 10:00:00 点击:

  核心提示:css3选择器。1 :first-of-type(:last-of-type)匹配属于其父元素的特定类型的首个子元素的每个元素例子:p:first-of-type{background:#ff0000...

css3选择器。

1 :first-of-type(:last-of-type)

匹配属于其父元素的特定类型的首个子元素的每个元素

例子:p:first-of-type{

background:#ff0000;

}

2 :only-of-type

匹配属于其父元素的特定类型的唯一子元素的每个元素

例子:p:only-of-type{

background:#cdfaf9;

}

3:only-child

匹配属于其父元素的唯一子元素的每个元素

例子:p:only-child{

background:#e6fbcd;

}

4 :nth-child(n) (nth-last-child(n))

匹配属于其父元素的第 N 个子元素,不论元素的类型。

n可以是数字、关键词或公式

例子:li:nth-last-child(2n){

background:#FF6600;

}

5 input:checked

匹配每个已被选中的 input 元素(只用于单选按钮和复选框)

例子:input:checked{

height:30px;

width:30px;

}

6 :not(selector)

匹配非指定元素/选择器的每个元素

例子:p:not(p){

color:#f96308;

Tags:CS SS S3 3选 
作者:网络 来源:lihang9188