Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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

              
                <!--
  Parsing the gradient list from http://uigradients.com/
  with the help of https://rawgit.com/
  shuffle and display it
  while animating the transition.
-->


<div class="helper">
<!-- This helper is needed to animate the gradients, as linear-gradient is not transitionable -->
</div>

<div class="title">
  Dance To Forget<br>
  <small><a href="http://uigradients.com/#DanceToForget">http://uigradients.com/#DanceToForget</a>
</div>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Montserrat);


html,
body{
  margin: 0;
  padding: 0;
  min-height: 100%;
}

html{
  position: relative;
  background: #FF4E50;
  background: linear-gradient(to left, #FF4E50 , #F9D423);
  transition: all .5s ease;
  overflow: hidden;
  font-family: Montserrat, 'Helvetica Neue', Helvetica, Arial, sans-serif;
}


.helper{
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  opacity: 0;
  transition: opacity 1s ease;
  
  &.active{
     opacity: 1;
  }
}

.title{
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  text-align: center;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 1px 2px 5px rgba(black,.2);
  z-index: 1000;
  
  a{
    color: #fff;
    text-transform: none;
    text-decoration: none;
    font-size: 12px;
    letter-spacing: 0;
  }
}
              
            
!

JS

              
                var uiGradientsUrl = 'https://cdn.rawgit.com/Ghosh/uiGradients/master/gradients.json';

var html   = $('html'),
    helper = $('.helper'),
    title  = $('.title'),
    gradientsList,
    activeGradient,
    i = 0;

$.getJSON(uiGradientsUrl, function(data) {
  gradientsList = data;
  // Shuffle Array
  gradientsList.sort(function() { return 0.5 - Math.random() });
});

var bgChangeInterval = setInterval(function(){
  // Get gradient
  activeGradient = gradientsList[i];
   
  // Create link to uigradients.com
  var link = 'http://uigradients.com/#' + activeGradient.name.replace(/\s+/g, '');
  title.html(activeGradient.name + '<br><small><a href="'+link+'">'+link+'</a></small>');
  
  // Flip target for transition
  var target = html;
  helper.removeClass('active');
  
  if (i%2 == 0){
    target = helper;
    html.removeClass('active');
  }
  
  // Set new gradient
  target.css({
    'background' : activeGradient.colors[0] ,
    'background' : 'linear-gradient(to left, ' + activeGradient.colors[0] + ' ,' + activeGradient.colors[1] + ')'
  }).addClass('active');
   
  // Set i to next i - if not the last one
  i = ( gradientsList.length < i ? 0 : i);
  i++;
  
}, 1500);
              
            
!
999px

Console