css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
              %h1 Responsive Table

%table.js-table-data
  %thead
    %tr
      %th Company
      %th Location
      %th{data: {label: 'Desc'}} Description
  %tr
    %td Acme Company, LLC
    %td Denver, CO
    %td Lorem ipsum dolor sit amet consectetur adipisicing elit. Eos necessitatibus obcaecati quibusdam.
  %tr
    %td Simple Corp
    %td Austin, TX
    %td Mollitia veritatis commodi deleniti provident quasi neque illum ipsa consequatur ullam facere, quidem minus nesciunt maxime architecto.
  %tr
    %td ABC Generic Company
    %td Seattle, WA
    %td Nihil officia natus voluptas, at quasi impedit animi enim doloremque architecto.
    
%p
  Blog post and instructions:
  %a{href: 'https://j.eremy.net/responsive-table/', target: '_blank'} https://j.eremy.net/responsive-table/
            
          
!
            
              /////////////////////
// *Most* of this is necessary,
// but change the appearance to your liking
/////////////////////
@media screen and (max-width: 767px)
  thead
    display: none
  tr
    display: block
    position: relative
    padding: 1.2em 0
    &:first-of-type
      border-top: 1px solid #ccc
  td
    display: table-row
    &:before
      content: attr(data-label)
      display: table-cell
      font-weight: bold
      padding: 0.2em 0.6em 0.2em 0
      text-align: right
    &:last-child:after
      content: ''
      position: absolute
      left: 0
      right: 0
      bottom: 0
      border-bottom: 1px solid #ccc
  
/////////////////////
// None of this is required,
// but it makes the demo pretty
/////////////////////
@import url('https://fonts.googleapis.com/css?family=Montserrat:500,700')
body
  padding: 5%
  font-family: 'Montserrat', sans-serif
  font-weight: 500
  line-height: 1.35
h1
  font-size: 1.8em
  margin-bottom: 0.8em
table
  margin-bottom: 2em
  text-align: left
@media screen and (min-width: 768px)
  body
    padding: 2.5em
  td, th
    padding: 0.4em 0.6em
    vertical-align: top
    border: 1px solid #ccc
  th
    background: #e1e1e1
    font-weight: bold
            
          
!
            
              $(document).ready(function(){
  $('.js-table-data td').each(function(){
    var tdIndex = $(this).index();
    if ($('tr').find('th').eq(tdIndex).attr('data-label')) {
      var thText = $('tr').find('th').eq(tdIndex).data('label');
    } else {
      var thText = $('tr').find('th').eq(tdIndex).text();
    }
    $(this).attr('data-label', thText + ':');
  });
})
            
          
!
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