how to use the :nth-child pseudo-class to target elements in between the first and last child elements.
Created
December 4, 2013 04:17
-
-
Save antoniocachuan/7782253 to your computer and use it in GitHub Desktop.
A Pen by Antonio.
This file contains hidden or 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
| <ul> | |
| <li>List item 1</li> | |
| <li>List item 2</li> | |
| <li>List item 3</li> | |
| <li>List item 4</li> | |
| <li>List item 5</li> | |
| <li>List item 6</li> | |
| <li>List item 7</li> | |
| <li>List item 8</li> | |
| <li>List item 9</li> | |
| <li>List item 10</li> | |
| </ul> |
This file contains hidden or 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(-n+5) { | |
| color: white; | |
| background-color: black; | |
| } | |
| /*selecciona numeros pares*/ | |
| /*Expresiones de lenguajes | |
| Seleccionara primero el tercero luego el quinto, septimo, es decir el 2n es el que le suma 2 en una secuencia | |
| -n+5 selecciona el quinto y luego va bajando uno a uno es decir 4,3,2,1 | |
| */ | |
| /*li:nth-child(2n+3) { | |
| color: white; | |
| background-color: black; | |
| }*/ | |
| /*li:nth-child(3n+4) { | |
| color: white; | |
| background-color: black; | |
| }*/ | |
| /*li:nth-child(-n+3) { | |
| color: white; | |
| background-color: black; | |
| }*/ | |
| /*solo voltea la lista comienza desde el fina y retrocede uno a uno | |
| li:nth-last-child(-n+3) { | |
| color: white; | |
| background-color: black; | |
| }*/ |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Selectors- Expresiones de lenguajes