Forked from rondevera/css-to-select-range-of-children.html
Created
May 3, 2017 16:59
-
-
Save yemster/3450904b5ca89ae914b33b7807129791 to your computer and use it in GitHub Desktop.
CSS selector for a range of 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> | |
<style> | |
/* How to select a range of children | |
* (Here, 3rd-7th children, inclusive): | |
*/ | |
ul li:nth-child(n+3):nth-child(-n+7) { | |
outline: 1px solid #0f0; | |
} | |
</style> | |
</head> | |
<body> | |
<ul> | |
<li>Child 1</li> | |
<li>Child 2</li> | |
<li>Child 3</li> | |
<li>Child 4</li> | |
<li>Child 5</li> | |
<li>Child 6</li> | |
<li>Child 7</li> | |
<li>Child 8</li> | |
<li>Child 9</li> | |
<li>Child 10</li> | |
</ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment