Home  >  Article  >  Web Front-end  >  HTML5新增的Css选择器、伪类介绍_html5教程技巧

HTML5新增的Css选择器、伪类介绍_html5教程技巧

WBOY
WBOYOriginal
2016-05-16 15:49:081844browse

选择器
p[name^=“my”]{font-size:14px}
选择器 ^= 讲规则应用到所有 name属性以“my”开头的

元素标签
p[name$=“my”]{font-size:14px}
选择器 $= 讲规则应用到所有 name属性以“my”结尾的

元素标签
p[name*=“my”]{font-size:14px}
选择器 $= 讲规则应用到所有 name属性包含“my”结尾的

元素上
选择器 > 、 + 、~
选择器>表示受影响的元素是第一个元素的子元素。
选择器+这 个选择器引用紧跟元素之后的元素,这两个元素必须有相同父级。
选择器~与+类似,但受影响的元素不一定紧跟第一个元素。

伪类与引用元素名称之间要加“:”
例:myclass:nth-child(2)
myclass元素中的第二个素
关键字“odd” ,“even”
myclass:nth-child(odd):影响其父元素索引位置为奇数的
myclass:nth-child(even):影响其父元素索引位置为偶数的

复制代码
代码如下:




1



2




1



2



1



2



效果如下:
1
2
1
2
1
2
否定伪类
:not(p){color:red}
除了

元素之外的其他元素都为red

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn