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

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

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              -var nRulers = 10;

div#main
  div#container
    div#rulers-wrap
      while nRulers--
        div.rulers
    span.strut
    span.text Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
  
  div.btn-wrap
    button.guideBtn Toggle guides
    div
      button.incdec FS -
      button.incdec FS +
      label#FS 0px
    div
      button.incdec LH -
      button.incdec LH +
      label#LH 0px
      label#EM 0em
  
            
          
!
            
              // lineHeight variable defines (besides spacing between baselines) the very first line's baseline position from the top of containing block 
// NB! when modifying typeface, re-run JS(ctrl-shift-5)

typeface   = Georgia
fontSize   = 16px  // min 15px
lineHeight = 25px  // min 1.2em

blockWidth  = 200px
blockHeight = 200px // 80vh
rulerThick  = 2px

.strut
  display inline-block
  height lineHeight
  width 15px  
  background-color alpha(black,50%)

.text
  vertical-align baseline
  font-family typeface
  font-size fontSize
  line-height lineHeight
  background-color alpha(cyan,30%)
  
.rulers
  margin-top (lineHeight - rulerThick)
  border 0
  border-bottom rulerThick
  border-color alpha(red, 40%)
  border-style solid

#rulers-wrap
  position absolute
  top rulerThick
  width 100%

#container
  display inline-block
  position relative
  overflow hidden
  height blockHeight
  width blockWidth

  // margin 5vh auto 0
  border 5px solid alpha(blue, 50%)
  background-color alpha(red, 10%)

#main
  margin 5vh auto 0
  width blockWidth*2.5

.btn-wrap
  display inline-block
  vertical-align top
  
.hidden
  visibility hidden
            
          
!
            
              $.C = $.Color
bgC = $('#container').css 'background-color'
borderC = $('#container').css 'border-color'
lineC = $('.text').css 'background-color'

$('.guideBtn').on 'click', ->
  $('.strut, #rulers-wrap').toggleClass 'hidden'
  $('#container')
  .css 'background-color', cHandler bgC 
  .css 'border-color', cHandler borderC
  $('.text').css 'background-color', cHandler lineC

$('.incdec').on 'click', ->
  label = $(this).text()
  prop = if label.slice(0,2)=='FS' then 'font-size' else 'line-height'
  v = if label.slice(-1)=='-' then -1 else +1
  $('.text').css prop, parseInt($('.text').css prop )+v+'px'
  lh = parseInt $('.text').css 'line-height'
  rulTh = parseInt $('.rulers').css 'border-bottom'
  $('.strut').css 'height', lh + 'px'
  $('.rulers').css 'margin-top', lh - rulTh + 'px'
  refreshFSLH()
  
cHandler = (color) ->
  (_,c)=>
    c = if $.C(c).alpha() then $.C(color).alpha(0) else color

refreshFSLH = ->   
  $('#FS').text $('.text').css 'font-size'
  $('#LH').text $('.text').css 'line-height'
  $('#EM').text String(
    parseInt($('.text').css('line-height')) /  parseInt($('.text').css('font-size'))
    ).slice(0,4) + 'em'

refreshFSLH()
            
          
!
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.

Console