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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

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

    %h2 Next section
    %h2 Third section
  font-family: Helvetica, sans-serif

body, html
  height: 100%

body, h1, h2
  margin: 0
  padding: 0

h1, h2, p
  padding: 0 40px
  background-color: #eee
  position: relative
  height: 100%
  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: ->
    resizeSection = debounce( =>
    , 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

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

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

Loading ..................