cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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.

            
              %section
  .inner
    %h1 Hero section
    %p Resize the browser window to see the section height and content position update.

%section
  .inner
    %h2 Next section
    
%section
  .inner
    %h2 Third section
            
          
!
            
              body
  font-family: Helvetica, sans-serif

body, html
  height: 100%

body, h1, h2
  margin: 0
  padding: 0

h1, h2, p
  padding: 0 40px
  
section:nth-child(odd)
  background-color: #eee
  
section
  position: relative
  height: 100%
   
.inner
  left: 0
  max-width: 960px
  margin: 0 auto
  position: absolute
  right: 0
  top: 50%
  -webkit-transform: translateY(-50%)
  -moz-transform: translateY(-50%)
  transform: translateY(-50%)
            
          
!
            
              class browserHeightSection

  constructor: ->
    @increaseSectionHeight()
    resizeSection = debounce( =>
      @increaseSectionHeight()
    , 50)

    window.addEventListener "resize", resizeSection

  increaseSectionHeight: =>
    windowHeight = window.innerHeight || document.documentElement.clientHeight

    $('section').height(windowHeight).each () ->
      section = $(this).find('.inner')
      sectionTopMargin = (section.height() / 2) * -1 + 'px'
      section.css('margin-top', sectionTopMargin)

  debounce = (func, wait, immediate) ->
    timeout = undefined
    ->
      context = this
      args = arguments
      later = ->
        timeout = null
        func.apply context, args  unless immediate
        return

      callNow = immediate and not timeout
      clearTimeout timeout
      timeout = setTimeout(later, wait)
      func.apply context, args  if callNow
      return

$ ->
  if $('.csstransforms').length == 0
    new browserHeightSection()

            
          
!
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