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 This is an example of the crossfade() function for blending background images.

      label.title Change Cross-Fade
      input(id="cross-fade-slider", type="range", min="0", max="100")
      label Cross Fade =  
      span.percentage-output 50%
    | .hero { background-image: cross-fade (<span class="css-output-value">50</span>% url(https://cdn-images-1.medium.com/max/1600/1*o_vIFnBwhQIXh4qrzEYz7A.jpeg), url(https://www.desktopbackground.org/download/1600x900/2011/05/01/196572_audrey-hepburn-wallpapers-high-resolution-and-quality-download_2560x1920_h.jpg)); }

  margin: 0

  height: 600px
  width: 100%
  // The cross fade % controls the opacity of the first image 
  // Note: to have a smooth transition with the slider, choose two images exactly the same size. Otherwise, you get a weird resizing thing.
    image: cross-fade(50% url(https://cdn-images-1.medium.com/max/1600/1*o_vIFnBwhQIXh4qrzEYz7A.jpeg), url(https://www.desktopbackground.org/download/1600x900/2011/05/01/196572_audrey-hepburn-wallpapers-high-resolution-and-quality-download_2560x1920_h.jpg))
    position: center
    size: cover
    repeat: no-repeat
  padding: 1rem
  margin: 0  
// slider controls

  display: flex
  justify-content: space-around
  max-width: 1200px
  margin: 2rem auto
  background: #f9f9f9
  padding: 1rem
  flex: 0 1 30%
  text-align: center
  font-size: 1.2rem
  font-weight: 700
  padding: 1rem 2rem
  line-height: 1.5
  border-left: 1px solid #ddd
  margin-left: 2rem
              $('#cross-fade-slider').on('input', function() {
  var $this = $(this);
  // the present slider value
  var sliderValue = $this.val();
  // output the present slider value
  $('.percentage-output').html(sliderValue + '%');
  // Webkit has a different way to write the function so you have to include that here, too
    'background-image' : 'cross-fade(' + sliderValue + '% url(https://cdn-images-1.medium.com/max/1600/1*o_vIFnBwhQIXh4qrzEYz7A.jpeg), url(https://www.desktopbackground.org/download/1600x900/2011/05/01/196572_audrey-hepburn-wallpapers-high-resolution-and-quality-download_2560x1920_h.jpg))',
    'background-image' : '-webkit-cross-fade(url(https://cdn-images-1.medium.com/max/1600/1*o_vIFnBwhQIXh4qrzEYz7A.jpeg), url(https://www.desktopbackground.org/download/1600x900/2011/05/01/196572_audrey-hepburn-wallpapers-high-resolution-and-quality-download_2560x1920_h.jpg), ' + sliderValue + '%)'
🕑 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 ..................