<span id="Label3"></p><span style="position: absolute; right: 0; top: 4px; cursor: pointer; font-weight: bold;"><span style="position: absolute; right: 0; top: 4px; cursor: pointer; font-weight: bold;">x</span></span>Table of Contents [1] Anchor point [2]ui element [3] structure pseudo class [4] other front words<p><p>Pseudo-classes are often confused with pseudo-elements, which are similar in effect to the fact that they are achieved by adding an actual element, and the Pseudo-class effect is similar to that achieved by adding an actual class. In fact CSS3 to differentiate between the two, the Pseudo-class is explicitly represented by a colon, while the pseudo-element is represented by two Colons. This article will detail the details of the Pseudo-class</p></p><p><p></p></p>Anchor Point<p><p>About the anchor point <a> there are 5 common pseudo-classes, respectively: link,:hover,:active,:focus,:visited</p></p><pre><pre>a:link{background-color:pink;} <span style="color: #008000;">/*</span> <span style="color: #008000;">magenta, not visited</span> <span style="color: #008000;">*/</span></pre></pre><p><p></p></p><pre><pre>a:hover{background-color:lightblue;} <span style="color: #008000;">/*</span> light <span style="color: #008000;">blue, Mouse Hover</span> <span style="color: #008000;">*/</span></pre></pre><p><p></p></p><pre><pre>a:active{background-color:lightgreen;} <span style="color: #008000;">/*</span> light <span style="color: #008000;">green, is being clicked</span> <span style="color: #008000;">*/</span></pre></pre><p><p></p></p><pre><pre>a:focus{background-color:lightgrey;} <span style="color: #008000;">/*</span> light <span style="color: #008000;">gray, with Focus</span> <span style="color: #008000;">*/</span></pre></pre><p><p></p></p><pre><pre>a:visited{color:orange;} <span style="color: #008000;">/*</span> the <span style="color: #008000;">font Color is orange and has been accessed</span> <span style="color: #008000;">*/</span> <span style="color: #008000;">/*</span> <span style="color: #008000;">[note]visited Pseudo-class can only set font color style</span> <span style="color: #008000;">*/</span></pre></pre><p><p></p></p><p><p><strong>Pseudo-class Order</strong></p></p><p><p>For Pseudo-class order, There is a love-hate, which represents the order of the Pseudo-class is link, visited, focus, hover, Active. But is it possible that the order of pseudo-classes can only be so? Why is this order?</p></p><p><p>It is important to have a rule in the CSS cascade, which is to overwrite the front, so the order of the pseudo-class needs to be carefully considered.</p></p><p><p>"1" link and visited must be in the front, and there is no order, otherwise the effect of link or visited will be overwritten</p></p><p><p>[note That]link and visited are called static pseudo-classes and can only be applied to hyperlinks</p></p><p><p>"2" hover, active, Focus These three pseudo-classes must be the focus, hover, active order, because in the focus state, also need to trigger hover and active, and to trigger active must first trigger hover, So the active is going to be behind Hover.</p></p><p><p>[note that]hover, active, and focus are called dynamic pseudo-classes and can be applied to any element, but Ie7-browser does not support: focus,:hover and: Active is only supported for <a> settings under Ie6-browser</p></p><p><p>So there are only two final sequences: link, visited, focus, hover, active or visited, link, focus, hover, Active</p></p><pre><pre>a:link{background-color:pink;} <span style="color: #008000;">/*</span> <span style="color: #008000;">magenta, not visited</span> <span style="color: #008000;">*/</span> <span style="color: #000000;">a:visited{color:orange;}</span> <span style="color: #008000;">/*</span> the <span style="color: #008000;">font Color is orange and has been accessed</span> <span style="color: #008000;">*/</span> <span style="color: #000000;">A:focus{background</span>-color:lightgrey;} <span style="color: #008000;">/*</span> light <span style="color: #008000;">gray, with Focus</span> <span style="color: #008000;">*/</span> <span style="color: #000000;">A:hover{background</span>-color:lightblue;} <span style="color: #008000;">/*</span> light <span style="color: #008000;">blue, Mouse Hover</span> <span style="color: #008000;">*/</span> <span style="color: #000000;">A:active{background</span>-color:lightgreen;} <span style="color: #008000;">/*</span> light <span style="color: #008000;">green, is being clicked</span> <span style="color: #008000;">*/</span></pre></pre><p><p></p></p><p><p></p></p>UI Element Pseudo-class<p><p>UI element Pseudo-class includes: enabled,:d isabled,: checked three, mainly for the form element in html, Ie8-browser does not support</p></p><pre><pre><span style="color: #000000;">: Enabled status: disabled not</span>available status:<span style="color: #0000ff;">checked</span> selected state </pre></pre><pre><pre><span style="color: #800000;">input:enabled</span> {<span style="color: #ff0000;"> border</span>:<span style="color: #0000ff;"> 1px solid black</span>; <span style="color: #ff0000;"> background-color</span>:<span style="color: #0000ff;"> Transparent</span>;} <span style="color: #800000;">input:disabled</span> {<span style="color: #ff0000;"> border</span>:<span style="color: #0000ff;"> none</span>; <span style="color: #ff0000;"> background-color</span>:<span style="color: #0000ff;"> Gray</span>;} <span style="color: #800000;">input:checked</span> {<span style="color: #ff0000;"> outline</span>:<span style="color: #0000ff;"> 2px solid LightBlue</span>;}</pre></pre><pre><span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Button</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">onclick</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "btn.disabled = false;"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>Button available<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Button</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">><br><</span></span><span style="color: #800000;"><span style="color: #800000;">Button</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">onclick</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "btn.disabled = true;"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>Button not available<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Button</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">><br><</span></span><span style="color: #800000;"><span style="color: #800000;">input</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">type</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "button"</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">ID</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "btn"</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">value</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "button"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">><br><</span></span><span style="color: #800000;"><span style="color: #800000;">BR</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span><span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">label</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>Male<span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">input</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">type</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "radio"</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">name</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "sex"</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;">/></</span></span><span style="color: #800000;"><span style="color: #800000;">label</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">><br><</span></span><span style="color: #800000;"><span style="color: #800000;">label</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>Female<span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">input</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">type</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "radio"</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">name</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "sex"</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;">/></</span></span><span style="color: #800000;"><span style="color: #800000;">label</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span></pre><p><p>[note that there can be no spaces between]input and enabled</p></p><p><p></p></p>Structure Pseudo-class<p><p>Structure Pseudo-class can be divided into the following 3 cases, Ie8-browser does not support</p></p><p><p>The following are the cases where E is the parent element and F is the child element</p></p><p><p>"1": nth-child (n),: nth-last-child (n), first-child, last-child,: only-child</p></p><pre><pre><span style="color: #000000;">E f:nth-child (n) Select the nth child element e F:nth-last-child (n) of the parent element to select the first child element of the parent Element's reciprocal nth Child element e f:first-child , and E F: Nth-child (1) is equivalent to the last child element of the E f:last-child parent element, and E F:nth-last-child (1) is the same as E F:only-child Select the parent element to contain only one child element</span></pre></pre><p><p>[note]:firsr-child and: Last-child only Ie6-browser does not support</p></p><p><p>n can be an integer (starting at 1), or it can be a formula, or it can be a keyword (even, odd)</p></p><pre><pre> P:first-child is not representative of <span style="color: #0000ff;">< </span> <span style="color: #800000;">p </span> <span style="color: #0000ff;">> the first child element of the </span>, but <span style="color: #0000ff;">< </span> <span style="color: #800000;">p </span> <span style="color: #0000ff;">> </span> <span style="color: #000000;"> element is the first child element of an element p > i:first-child matches all </span> <span style="color: #0000ff;">< </span> <span style="color: #800000;">p </span> <span style="color: #0000ff;">> The first <span in the < span> element style= "color: #0000ff;" >< </span> <span style="color: #800000;">i </span> <span style="color: #0000ff;">> </span> <span style="color: #000000;"> element p:first-child I matches all </span> as the first child element <span style="color: #0000ff;">< </span> <span style="color: #800000;">p </span> <span style="color: #0000ff;">> </span> all <span style="color: #0000ff;">< </span> <span style="color: #800000;">i </span> <span style="color: #0000ff;">> </span> element </span></pre></pre><pre><pre><span style="color: #800000;">Li:nth-child (odd)</span> {<span style="color: #ff0000;">color</span>:<span style="color: #0000ff;"> Red</span>;} <span style="color: #800000;">Li:nth-last-child (3)</span> {<span style="color: #ff0000;">color</span>:<span style="color: #0000ff;"> Green</span>;} <span style="color: #800000;">Li:first-child</span> {<span style="color: #ff0000;">color</span>:<span style="color: #0000ff;"> Blue</span>;} <span style="color: #800000;">Li:last-child</span> {<span style="color: #ff0000;">color</span>:<span style="color: #0000ff;"> yellow</span>;} <span style="color: #800000;">Div:only-child</span> {<span style="color: #ff0000;">Background-color</span>:<span style="color: #0000ff;">lightgrey</span>;}</pre></pre><pre><span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">ul</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Li</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">><</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>First Div<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></</span></span><span style="color: #800000;"><span style="color: #800000;">Li</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Li</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">><</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>A second Div<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></</span></span><span style="color: #800000;"><span style="color: #800000;">Li</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Li</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">><</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>A third Div<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></</span></span><span style="color: #800000;"><span style="color: #800000;">Li</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Li</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">><</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>A fourth Div<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></</span></span><span style="color: #800000;"><span style="color: #800000;">Li</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Li</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">><</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>A fifth Div<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></</span></span><span style="color: #800000;"><span style="color: #800000;">Li</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Li</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">><</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>A sixth Div<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></</span></span><span style="color: #800000;"><span style="color: #800000;">Li</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">ul</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span></pre><p><p></p></p><p><p>"2": nth-of-type (n),: nth-last-of-type (n),: first-of-type,: last-of-type,: only-of-type</p></p><pre><pre><span style="color: #000000;">E f:nth-of-type (n) Select the parent element with the nth child element of the specified type E f:nth-last-of-type (n) Select the parent element with the specified type of the reciprocal nth child element e F:first-of-type Selects the 1th child element in the parent element with the specified type, with e f:nth-of-type (1) the same e f:last-of-type selects the last 1 child elements in the parent element with the specified type, with e f:nth-last-of-type (1) Same as E F:only-of-type Select a parent element that contains only one child element of the same type </span></pre></pre><pre><pre><span style="color: #000000;">. box div:nth-of-type (even) {color:red;}. box P:nth-last-of-type (3) {color:green;}. Box div:first-of-type{color:blue;}. Box p:last-of-type{color:yellow;}. Box div:only-of-type{color:pink;}</span></pre></pre><pre><span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">class</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "box"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>First Div<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">P</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>First P<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">P</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>A second Div<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">P</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>A second P<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">P</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">class</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "in"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>A third Div<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">P</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>A third P<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">P</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span><span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">class</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "box"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>A fourth Div<span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Div</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span></pre><p><p></p></p><p><p>"3": root,: not,: empty,: Target</p></p><pre><pre>: Root selects the root element of the document, that is, the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service