Is it possible to select multiple children past a defined number with CSS selectors?
I’d like to hide all list items past #3:
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li> <!-- hide this -->
<li>5</li> <!-- hide this -->
</ul>
<style>
ul li:nth-child(X) {
display: none;
}
</style>
I do not know which browser supports this, but you can pass a formula to :nth-of-type():
Further details on: http://www.w3schools.com/cssref/sel_nth-of-type.asp
Edit
I altered it from (n+4) to (1n+4) since the first version works but isn’t valid. I use this in media queries to hide cut-down items on smaller screens.
Example: