Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h2>#CSS: VISUALIZANDO nth-child
  <div class="sub">(by <a href="http://www.oloblogger.com">Oloman</a>)</div>
</h2>
<BR/>
HTML
<BR/>
<p>&lt;ul&gt;<br/>&lt;li&gt;1&lt;/li&gt;&nbsp;&lt;li&gt;2&lt;/li&gt;&nbsp;&lt;li&gt;3&lt;/li&gt;&nbsp;&lt;li&gt;4&lt;/li&gt;
 <br/>&lt;/ul&gt;
</p>
<BR/>
<BR/>
<BR/>
PRIMER ELEMENTO
<BR/>
<p>ul li:first-child</p>
<ul class="uno">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
ULTIMO ELEMENTO
<BR/>
<p>ul li:last-child</p>
<ul class="dos">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
UN ELEMENTO CONCRETO (QUINTO)
<BR/>
<p>ul li:nth-child(5)</p>
<ul class="tres">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
PENÚLTIMO ELEMENTO
<BR/>
<p>ul li:nth-last-child(2)</p>
<ul class="quince">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
ANTEPENÚLTIMO ELEMENTO
<BR/>
<p>ul li:nth-last-child(3)</p>
<ul class="dieciseis">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
TODOS LOS IMPARES
<BR/>
<p>ul li:nth-child(odd)</p>
<ul class="cuatro">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
TODOS LOS PARES
<BR/>
<p>ul li:nth-child(even)</p>
<ul class="cinco">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
TODOS LOS MÚLTIPLOS DE 3
<BR/>
<p>ul li:nth-child(3n)</p>
<ul class="seis">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
TODOS LOS MÚLTIPLOS DE 3 MÁS 2
<br>
(El cero es el primer múltiplo)
<BR/>
<p>ul li:nth-child(3n+2)</p>
<ul class="siete">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
DEL CUARTO HASTA EL ÚLTIMO
<BR/>
<p>ul li:nth-child(n+4)</p>
<ul class="ocho">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
DEL CUARTO HASTA EL PRIMERO
<BR/>
<p>ul li:nth-child(-n+4)</p>
<ul class="nueve">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
DEL CUARTO AL NOVENO
<br/>
(del cuarto hacia último +
<br/>del noveno hacia primero)
<BR/>
<p>ul li:nth-child(n+4):nth-child(-n+9)</p>
<ul class="diez">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
SÓLO LOS PARES ENTRE CUARTO Y NOVENO
<BR/>
<p>li:nth-child(n+4):nth-child(even):nth-child(-n+9)</p>
<ul class="once">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
SÓLO LOS MÚLTIPLOS DE 3 ENTRE CUARTO Y NOVENO
<BR/>
<p>li:nth-child(n+4):nth-child(3n):nth-child(-n+9)</p>
<ul class="doce">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
SÓLO LOS PARES MÚLTIPLOS DE 3
<BR/>
<p>li:nth-child(even):nth-child(3n)</p>
<ul class="trece">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
SÓLO PARES Y MÚLTIPLOS DE TRES ENTRE CUARTO Y NOVENO
<BR/>
<p>li:nth-child(n+4):nth-child(even):nth-child(3n):nth-child(-n+9)</p>
<ul class="catorce">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
              
            
!

CSS

              
                body, html {
  margin: 0;
  padding: 0;
  outline: 0;
  border: 0;
  font-size: 24px;
  font-weight: bold;
  text-align: center;
  background: #eee;
  font-family: sans-serif;
  box-sizing: border-box;
}
h2 {
  display: inline-block;
  margin: 60px auto;
  padding: 10px 30px;
  color: white;
  background: black; 
  border-radius: 8px;
  font-size: 24px;
  line-height: 40px;
  box-sizing: border-box;
}
h2 .sub {
  font-size: 70%;
}
a {
  color: white;
}
p {
  display: inline-block;
  margin: 20px auto 5px;
  padding: 10px;
  border-radius: 8px;
  background: #cc0000;
  color: white;
}
ul {
  width: 90%;
  margin: 20px auto;
  padding: 0;
  list-style: none;
  text-align: center;
  counter-reset: contar;
  border-bottom: 2px groove #fff;
}
li {
  display: inline-block;
  width: 40px;
  height: 40px;
  margin: 20px 4px;
  background: black; 
  border-radius: 50%;
  font-size: 24px;
  line-height: 40px;
}
ul:nth-of-type(14) {
  border-bottom: 0 !important;
}
li:before {
  content: counter(contar);
  counter-increment: contar;
  color: white;
}
.uno li:first-child,
.dos li:last-child,
.tres li:nth-child(5),
.cuatro li:nth-child(odd),
.cinco li:nth-child(even),
.seis li:nth-child(3n),
.siete li:nth-child(3n+2),
.ocho li:nth-child(n+4),
.nueve li:nth-child(-n+4),
.diez li:nth-child(n+4):nth-child(-n+9),
.once li:nth-child(n+4):nth-child(even):nth-child(-n+9),
.doce li:nth-child(n+4):nth-child(3n):nth-child(-n+9),
.trece li:nth-child(even):nth-child(3n),
.catorce li:nth-child(n+4):nth-child(even):nth-child(3n):nth-child(-n+9),
.quince li:nth-last-child(2),
.dieciseis li:nth-last-child(3)
{
  background: #cc0000;
}
              
            
!

JS

              
                
              
            
!
999px

Console