Universal sibling selector

This selector has a wider matching range than adjacent sibling selectors, and there is no "adjacent" restriction.

E ~ F

The above is the format for creating a universal sibling selector. E and F must have the same parent element, and the F element is behind the E element. The code example is as follows:

<!DOCTYPE html>

<html>

<head>

<meta charset=" utf-8">

<meta name="author" content="http://ask.php.cn/ " />

<title>php Chinese website</title>

<style type="text/css">

li{color: blue}

.antzone ~ li{

color:red;

}

</style>

</ head>

<body>

<ul>

<li>php中文网一</li>

<li class="antzone">php中文网二</li>

<li>php中文网三</li>

<li>php中文网四< ;/li>

</ul>

</body>

</html>

The above code can replace the antzone The font of all li elements is set to red.


Continuing Learning
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://ask.php.cn/" /> <title>CSS教程</title> <style type="text/css"> div~p{color:blue} </style> </head> <body> <div>php中文网一</div> <p>php中文网二</p> <span>php中文网三</span> <p>php中文网四</p> </body> </html>
submitReset Code