cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

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.

            
              <section class="container">
  <h1>Demo: nth-child explained - Expression</h1>

  <h2>Expression - example 1</h2>
  
  <ul class="nce nce4">
   <li>child element 1</li>
   <li>child element 2</li>
   <li>child element 3</li>
   <li>child element 4</li>
   <li>child element 5</li>
   <li>child element 6</li>
   <li>child element 7</li>
   <li>child element 8</li>
   <li>child element 9</li>
   <li>child element 10</li>
  </ul>
  
  <h2>Expression - example 2</h2>
  
  <ul class="nce nce5">
   <li>child element 1</li>
   <li>child element 2</li>
   <li>child element 3</li>
   <li>child element 4</li>
   <li>child element 5</li>
   <li>child element 6</li>
   <li>child element 7</li>
   <li>child element 8</li>
   <li>child element 9</li>
   <li>child element 10</li>
  </ul>
  
  <h2>Expression - example 3</h2>
  
  <ul class="nce nce6">
   <li>child element 1</li>
   <li>child element 2</li>
   <li>child element 3</li>
   <li>child element 4</li>
   <li>child element 5</li>
   <li>child element 6</li>
   <li>child element 7</li>
   <li>child element 8</li>
   <li>child element 9</li>
   <li>child element 10</li>
  </ul>
  
  <h2>Expression - example 4</h2>
  
  <ul class="nce nce7">
   <li>child element 1</li>
   <li>child element 2</li>
   <li>child element 3</li>
   <li>child element 4</li>
   <li>child element 5</li>
   <li>child element 6</li>
   <li>child element 7</li>
   <li>child element 8</li>
   <li>child element 9</li>
   <li>child element 10</li>
  </ul>

  <a href="http://www.matt-harris.net/notes/nth-child-explained" class="h4">Back to the article</a>
</section>

<footer class="footer" role="contentinfo">
  <div class="container">

    <h4>Find me here</h4>

    <ul class="footer__social list--unstyled">
      <li class="footer__social-item">
        <a class="icon-social icon-social--twitter" href="https://twitter.com/matty_h"></a>
      </li>
      <li class="footer__social-item">
        <a class="icon-social icon-social--codepen" href="https://codepen.io/matt-harris/"></a>
      </li>
      <li class="footer__social-item">
        <a class="icon-social icon-social--github" href="https://github.com/matt-harris"></a>
      </li>
    </ul>

    <span class="footer__text">Built with <a href="https://www.outlinecss.co.uk">Outline</a></span>

    <span class="footer__text">Copyright © 2016 matt-harris.net | Stealing is naughty.</span>

  </div>
</footer>
            
          
!
            
              @import "compass/css3";

// variables
$color-primary: #39beef;
$color-secondary: #ea5375;
$color-tertiary: #187da4;
$color-white: #fff;
$color-grey: #ccc;
$font-primary: 'Open Sans', Arial, sans-serif;

// demo

.nce {
  list-style-type: none;
  margin: 1.2em 0;
  padding: 0;
  color: $color-white;
  
  li {
    margin-bottom: 0.5em;
    padding: .5em 1em;
    background-color: $color-primary;
  }
}

.nce4 li:nth-child(3n+4),
.nce5 li:nth-child(n+4),
.nce6 li:nth-child(-n+8),
.nce7 li:nth-child(5n-2) {
  background-color: $color-secondary;
}
            
          
!
            
              // Demo: nth-child explained - Expression
// http://www.matt-harris.net/notes/nth-child-explained
            
          
!
999px
Loading ..................

Console