Skip to content

Instantly share code, notes, and snippets.

@liuyanghejerry
Forked from anonymous/index.html
Last active September 15, 2015 09:06
Show Gist options
  • Save liuyanghejerry/20c53f3dba60a2435d86 to your computer and use it in GitHub Desktop.
Save liuyanghejerry/20c53f3dba60a2435d86 to your computer and use it in GitHub Desktop.
css that only select `ul` has and only has 5 children.
<!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>
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