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

              
                <h1>Fun with line-height</h1>

<section> 
  <h2>Funsville</h2>
  <p>When you know the line-height, you can make a linear-grdient that has hard color stops in between each line of text. Gaperiam nemo saepe sunt enim, perferendis aut numquam est doloremque tempora molestias in vero? Eius animi odit earum, fugit optio.</p>
</section>

<section>
  <h2>Emphasize Start</h2>
  <p>It's easiest when the background starts on top of the text like in this case, consectetur adipisicing elit. Corrupti cupiditate, aperiam nemo saepe sunt enim, perferendis aut numquam est doloremque tempora molestias in vero? Eius animi odit earum, fugit optio. Corrupti cupiditate, aperiam nemo saepe sunt enim, perferendis aut numquam est doloremque tempora molestias in vero? Eius animi odit earum, fugit optio</p>
</section>

<section>
  <h2>Fade Out Bottom</h2>
  <p>But we can also make it work for the bottom of text (depite its length) by using calc() in the gradients, substracting it from the elements full height. Sit amet, consectetur adipisicing elit. Corrupti cupiditate, aperiam nemo saepe sunt enim, perferendis aut numquam est doloremque tempora molestias in vero? Eius animi odit earum, fugit optio. Corrupti cupiditate, aperiam nemo saepe sunt enim, perferendis aut numquam est doloremque tempora molestias in vero? Eius animi odit earum, fugit optio</p>
</section>

<section> 
  <h2>Lines</h2>
  <p>There are plenty of little things that can screw this up, but if you're careful, you can create a 1px gradient that repeats at the current line-height so that it's between lines of text no matter what. I first saw Lea Verou do this. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corrupti cupiditate, aperiam nemo saepe sunt enim, perferendis aut numquam est doloremque tempora molestias in vero? Eius animi odit earum, fugit optio.</p>
</section>

<section>
  <h2>Ticks</h2>
  <p>You can set the background-size of an image to match the line-height, so that it's always the same size of a line. Perferendis Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corrupti cupiditate, aperiam nemo saepe sunt enim, perferendis aut numquam est doloremque tempora molestias in vero? Eius animi odit earum, fugit optio. Corrupti cupiditate, aperiam nemo saepe sunt enim, perferendis aut numquam est doloremque tempora molestias in vero? Eius animi odit earum, fugit optio</p>
</section>
              
            
!

CSS

              
                $lh: 1.4em;

body {
  font-size: 1em;
  line-height: $lh;
}

h1 {
  background: #333;
  margin: 0;
  padding: 5% 20%;
  text-transform: uppercase;
  color: #eee;
  font-size: 2em;
}

section {
  padding: 5% 20%;
  h2 {
    margin: 0 0 $lh 0;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5em;
    font-size: 1em;
  }
  p {
    margin: 0 0 1em 0;
  }
  @media (max-width: 400px) {
    padding: 10%;
  }
}

section:nth-of-type(1) {
  background: #082838;
  @supports (-webkit-background-clip: text) {
    p {
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-image: linear-gradient(
        to bottom,
        #9588DD,
        #9588DD $lh,
        #DD88C8 $lh,
        #DD88C8 $lh*2,
        #D3DD88 $lh*2,
        #D3DD88 $lh*3,
        #88B0DD $lh*3,
        #88B0DD);
    }
  }
}

section:nth-of-type(2) {
  background: #111;
  p {
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-image: linear-gradient(
      to bottom,
      rgba(white, 0.8),
      rgba(white, 0.8) $lh,
      rgba(white, 0.6) $lh,
      rgba(white, 0.6) $lh*2,
      rgba(white, 0.4) $lh*2,
      rgba(white, 0.4) $lh*3,
      rgba(white, 0.2) $lh*3,
      rgba(white, 0.2));
  }
}

section:nth-of-type(3) {
  background: #333;
  p {
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-image: linear-gradient(
      to bottom,
      rgba(white, 0.8),
      rgba(white, 0.8) calc(100% - 66px),
      rgba(white, 0.6) calc(100% - 66px),
      rgba(white, 0.6) calc(100% - 44px),
      rgba(white, 0.4) calc(100% - 44px),
      rgba(white, 0.4) calc(100% - 22px),
      rgba(white, 0.2) calc(100% - 22px),
      rgba(white, 0.2));
  }
}

section:nth-of-type(4) {
  padding: $lh*2;
  background: #082838;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(white, 0)   0,
    rgba(white, 0) $lh/1em*16px-1,
    rgba(white, 0.1) $lh/1em*16px-1,
    rgba(white, 0.1) $lh/1em*16px
  );
  p {
    opacity: 0.75;
    color: white;
  }
}

section:nth-of-type(5) {
  background: #111;
  p {
    color: #999;
    background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/tick.svg");
    padding-left: $lh*2;
    background-size: $lh $lh;
    background-repeat: repeat-y;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console