-
-
Save liuyanghejerry/20c53f3dba60a2435d86 to your computer and use it in GitHub Desktop.
css that only select `ul` has and only has 5 children.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=0,minimal-ui"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
li:nth-child(1):nth-last-child(5), | |
li:nth-child(1):nth-last-child(5) ~ li { | |
background-color: pink; | |
} | |
</style> | |
</head> | |
<body> | |
<ul> | |
<li>0001</li> | |
<li>0002</li> | |
<li>0003</li> | |
<li>0004</li> | |
<li>0005</li> | |
</ul> | |
<script id="jsbin-source-css" type="text/css">li:nth-child(1):nth-last-child(5), | |
li:nth-child(1):nth-last-child(5) ~ li { | |
background-color: pink; | |
}</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
li:nth-child(1):nth-last-child(5), | |
li:nth-child(1):nth-last-child(5) ~ li { | |
background-color: pink; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment