Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

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

%h2 Another Table

%table.js-table-data
  %thead
    %tr
      %th{data: {label: '1'}} Label One
      %th{data: {label: '2'}} Label Two
      %th{data: {label: '3'}} Label Three
  %tr
    %td A
    %td B
    %td C
    
%p
  Blog post and instructions:
  %a{href: 'https://j.eremy.net/responsive-table/', target: '_blank'} j.eremy.net/responsive-table
              
            
!

CSS

              
                /////////////////////
// *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, h2
  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
              
            
!

JS

              
                $(document).ready(function(){  
  $('.js-table-data').each(function(){
    table = $(this);
    tableRow = table.find('tr');
    table.find('td').each(function(){
      tdIndex = $(this).index();
      if ($(tableRow).find('th').eq(tdIndex).attr('data-label')) {
        thText = $(tableRow).find('th').eq(tdIndex).data('label');
      } else {
        thText = $(tableRow).find('th').eq(tdIndex).text();
      }
      $(this).attr('data-label', thText + ':');
    });
  });
});
              
            
!
999px

Console