css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <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>
            
          
!
            
              $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;
  }
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console