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

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="container">
  <div class="inner-content">
    <div class="box box_1"><h2>My title</h2><p>Completely maintain tactical collaboration and idea-sharing whereas technically sound models. Continually exploit granular innovation rather than empowered action items.</p><footer></footer></div>
    <div class="box box_2"><h2>My title</h2><p>Completely maintain tactical collaboration and idea-sharing whereas technically sound models. Continually exploit granular innovation rather than empowered action items.</p><footer></footer></div>
  <div class="box box_3"><h2>My title</h2><p>Completely maintain tactical collaboration and idea-sharing whereas technically sound models. Continually exploit granular innovation rather than empowered action items.</p><footer></footer></div>
  <div class="box box_4"><h2>My title</h2><p>Completely maintain tactical collaboration and idea-sharing whereas technically sound models. Continually exploit granular innovation rather than empowered action items.</p><footer></footer></div>
  </div>
</div>
              
            
!

CSS

              
                /* The logic is quite simple : have a fixed height container with display:flex property. Blocks inside have lower heights. Odd and even are self-aligned with flex-start or flex-end properties */

html{
  margin:0;
  padding:0;
  width:100%;
  height:100%;
}
body{
  width:100%;
  height:100%;
  font-family:Arial, sans-serif;
  font-size:16px;
  line-height:30px;
  padding:20px;
  margin:0;
}
*{
  -webkit-box-sizing: border-box; 
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
h2{
  margin: 0;
  padding: 10px; 0
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 15px;
  font-size:18px
}
.container{
  min-height: 1500px;
  display:flex;
  justify-content:center;
  align-items:center;
}
.inner-content{
    display:flex;
    justify-content:center;
    align-items:center;
    width:1000px;
    height:600px;
}
.box{
    height:400px;
    width:250px;
    background-color:#fff;
    display:flex;
    justify-content:flex-around;
    flex-direction:column;
  -webkit-box-shadow: 5px 5px 15px 5px rgba(0,0,0,0.42);box-shadow: 5px 3px 12px 5px rgba(0,0,0,0.1);
}
.box p{
    padding:20px;
    flex:1;
}
footer{
    -ms-flex-item-align: end;
    align-content: flex-end;
    background-color:#000;
    height:30px;
    display: block;
    position:relative
}
.box_1, .box_3{
    -ms-flex-item-align: end;
    align-self: flex-end;
    opacity: 0;
    -webkit-transform: translateY(-100px);
    -ms-transform: translateY(-100px);
    transform: translateY(-100px);
    overflow: hidden;
    -webkit-transition: opacity 0.5s,-webkit-transform 0.7s;
    transition: opacity 0.5s,-webkit-transform 0.7s;
    -o-transition: opacity 0.5s,transform 0.7s;
    transition: opacity 0.5s,transform 0.7s;
    transition: opacity 0.5s,transform 0.7s,-webkit-transform 0.7s;
    margin-bottom: 20px;
}
.box_1.animated, .box_3.animated {
    opacity: 1;
    -webkit-transform: translateY(0px);
    -ms-transform: translateY(0px);
    transform: translateY(0px);
}


.box_2,.box_4{
    background-color:#eee;
    -ms-flex-item-align: start;
    align-self: flex-start;  
    opacity: 0;
    -webkit-transform: translateY(100px);
    -ms-transform: translateY(100px);
    transform: translateY(100px);
    overflow: hidden;
    -webkit-transition: opacity 0.5s,-webkit-transform 0.7s;
    transition: opacity 0.5s,-webkit-transform 0.7s;
    -o-transition: opacity 0.5s,transform 0.7s;
    transition: opacity 0.5s,transform 0.7s;
    transition: opacity 0.5s,transform 0.7s,-webkit-transform 0.7s;
    margin-bottom: 20px;

}
.box_2.animated, .box_4.animated{
    opacity: 1;
    -webkit-transform: translateY(0px);
    -ms-transform: translateY(0px);
    transform: translateY(0px);
}
              
            
!

JS

              
                var $animation_elements = $('.box');
var $window = $(window);

function check_if_in_view() {
  var window_height = $window.height();
  var window_top_position = $window.scrollTop();
  var window_bottom_position = (window_top_position + window_height);
 
  $.each($animation_elements, function() {
    var $element = $(this);
    var element_height = $element.outerHeight();
    var element_top_position = $element.offset().top;
    var element_bottom_position = (element_top_position + element_height);
 
   
    if ((element_bottom_position >= window_top_position) &&
        (element_top_position <= window_bottom_position)) {
      $element.addClass('animated');
    } else {
      $element.removeClass('animated');
    }
  });
}

$window.on('scroll resize', check_if_in_view);
$window.trigger('scroll');
	  
              
            
!
999px

Console