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. 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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                table
  thead
    tr
      th.blank
      - for (c=0;c<20;c++) {
        th='col ' + c
      - }      
  tbody
    - for (r=0;r<30;r++) {
      tr
        th= 'row '+r 
        - for (c=0;c<20;c++) {
          td='(' + c + ', ' + r + ')'
        - }      
    - }    

              
            
!

CSS

              
                * {
  box-sizing:border-box;
}

html,
body {
  height:100%;
}


table {
  display:block;
  position:relative;
  
  &:after,
  &:before {
    content:'';
    display:block;
    position:fixed;
    z-index:2000;
    top:0;
    left:0;
    transition:box-shadow 250ms ease-out;
  }

  &.moreLeft:after {
    box-shadow:4px 0 14px rgba(0,0,0,0.2);
    height:100%;
    width:150px;
  }

  &.moreTop:before {
    box-shadow:0 4px 14px rgba(0,0,0,0.2);
    height:40px;
    width:100%;
  }

  tr {
    display:flex;
    flex-direction: row;
    flex-wrap:nowrap;
    justify-content:flex-start;
  }
  td,
  th {
    display:flex;
    flex:1 0 150px;
    padding:10px;
    text-align:center;
    border:1px solid #ccc;
    background:#fff;
    width:150px;
  }
  tbody {
    margin-top:40px;
    margin-left:150px;
    position:relative;
    z-index:100;
    th {
      backface-visibility: hidden;
      position:fixed;
      z-index:80;
      left:0;
    }
  }
  thead {
    backface-visibility: hidden;
    position:fixed;
    z-index:200;
    top:0;
    margin-left:150px;
    th {
      height:40px;
      z-index:100;
      
      &.blank {
        backface-visibility: hidden;
        position:fixed;
        z-index:200;
        top:0;
        left:0;
      }
    }
  }
}

              
            
!

JS

              
                /*
  To Do:
   - Support variable height and width cells
   - Specify which rows/columns to freeze
   - Convert to plugin w/fallback for non-flexbox browsers.
   - Offset scrollable area so the scrollbars do not extend over fixed headers.
   - Better mobile performance
*/

$(function(){
  function repositionFixedHeaders() {
    var $hCol=$('tbody th');
    var $hRow=$('thead');
    var $table=$('table');
    var offsetTop = $('body').scrollTop();
    var offsetLeft = $('body').scrollLeft();
    
    requestAnimationFrame(repositionFixedHeaders);
    
    // move fixed header row
    $hRow.css('left',-offsetLeft);
    
    // move fixed header column
    $hCol.each(function() {  
      var vertOffset = $(this).parent().offset().top;
      $(this).css('top',vertOffset-offsetTop);
    });
    
    // indicate horizontal scroll
    if (offsetLeft > 0) {
      if (!$table.hasClass('moreLeft')) {
        $table.addClass('moreLeft');
      }
    } else {
      $table.removeClass('moreLeft');
    }
    
    // indicate vert scroll
    if (offsetTop > 0) {
      if (!$table.hasClass('moreTop')) {
        $table.addClass('moreTop');
      }
    } else {
      $table.removeClass('moreTop');
    }    
        
  }
  
  repositionFixedHeaders();
});
              
            
!
999px

Console