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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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

              
                <div class="row">
  <div class="header col-md-12">
    <h1>Click the Button</h1>
  </div>
  <div class="content col-md-12">
    <div class="button">You know you want to!</div>
    <h1 class="sentence title">Fancy Slide In Text</h1>
    <h3 class="sentence subtitle">Embrace the fanciness!</h3>
  </div>
</div>
              
            
!

CSS

              
                .row {
  margin: 70px auto 30px auto;
  max-width: 1000px;
  text-align: center;
}
.header h1{
  margin-bottom: 30px;
}
.content{
  text-align: center;
}

.button {
  display: inline-block;
  padding: 12px 18px;
  background: #eee;
  cursor: pointer;
  margin: 10px 0px 20px 10px;
  border-bottom: solid 3px #eee;
  transition: all 220ms ease-out;
}
.button:active,
.button:hover{
  background: #9b59b6;
  color: #fff;
  border-bottom: solid 3px #8e44ad;
}

.title{
  font-family: 'Roboto', sans-serif;
  font-size: 2.9em;
  letter-spacing: 0.75px;
  text-transform: uppercase;
  font-weight: 600;
}
.subtitle{
  font-family: 'Roboto', sans-serif;
  font-size: 1.75em;
  font-weight: 300;
}
.sentence {
  color: #2c3e50;
}
.sentence span{
  opacity: 0;
  position: relative;
  display: inline-block;
}
.sentence span.active {
  animation: bounceUp 600ms ease 0ms 1 normal both;
}

/*bounce top in*/
@keyframes bounceUp {
  0% {
    transform: translate3d(0px, 0px, 0px);
    opacity: 0;
  }
  50% {
    transform: translate3d(0px, -50px, 0px);
    opacity: 0.7;
  }
  80% {
    transform: translate3d(0px, 20px, 0px);
    opacity: 1;
  }
  100%{
    transform: translate3d(0px, 0px, 0px);
    opacity: 1;
  }
}


              
            
!

JS

              
                
//go through a sentence, wrap its characters with spans
function setUpCharacters(){
  
  var $sentences = $('.sentence'); 
  //run for each sentence
  $sentences.each(function(){
    
    var $sentence = $(this);
    var newContent = '';
    
    //go through all characters of the sentence
    for(i = 0; i < $sentence.text().length; i++){
      var substring = $sentence.text().substr(i, 1);
      //if we have a character, wrap it
      if(substring != " "){
        newContent += '<span>' + substring + '</span>';
      }else{
        newContent += substring;
      } 
    }
    //replace content
    $sentence.html(newContent); 
  }); 
}
setUpCharacters();


//go through a sentence and trigger activate state
function triggerCharacters(){
  
  var sentenceCounter = 0;
  var sentenceDelay = 700;
  $('.sentence').each(function(){
    
    var $sentence = $(this);
    //trigger for each sentence
    setTimeout(function(){
      
      var $spans = $sentence.find('span');

      var spanCounter = 0;
      var spanDelay = 50;

      //loop through all spans and activate
      $spans.each(function(){

        var $span = $(this);
        //trigger a timeout so each span is offset
        setTimeout(function(){
          $span.toggleClass('active');
        }, (spanCounter * spanDelay));

        spanCounter++; 
      }); 
      
    }, (sentenceCounter * sentenceDelay));
    
    sentenceCounter++;
  });

}

//for our example, trigger character animations on button click
$('.button').on('click', function(){
  triggerCharacters();
});


              
            
!
999px

Console