Home > Web Front-end > H5 Tutorial > body text

Introduction to new CSS selectors and pseudo-classes in HTML5_html5 tutorial skills

WBOY
Release: 2016-05-16 15:49:08
Original
1944 people have browsed it

Selector
p[name^="my"]{font-size:14px}
Selector^= applies the rule to all

element tags
whose name attribute starts with "my" p[name$="my"]{font-size:14px}
Selector$= applies the rule to all

element tags whose name attribute ends with "my"
p[name*= "my"]{font-size:14px}
Selector$= applies the rule to all

elements whose name attribute contains "my" at the end
Selector> , ,~
Selector > indicates that the affected element is a child of the first element.
Selector This selector refers to the element immediately following the element. The two elements must have the same parent.
Selector~ is similar to , but the affected element does not necessarily follow the first element.

Add ":" between the name of the pseudo-class and the referenced element
Example: myclass:nth-child(2)
The second element in the myclass element
Keyword "odd " , "even"
myclass:nth-child(odd): affects the
whose parent element index position is odd number
myclass:nth-child(even): affects the
whose parent element index position is even number

Copy code
The code is as follows:




1



2




1



2



1



2



Effect As follows:
1
2
1
2
1
2
Negative pseudo-class
:not(p){color:red} except< All elements other than the ;p> element are red
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template