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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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.

HTML

            
              <h2>Collapse to Accordions</h2>
<div class="Rtable Rtable--4cols Rtable--collapse js-RtableAccordions">
  
  <button class="Accordion" role="tab" aria-selected="true">Ned</button>
  <div class="Rtable-cell  Rtable-cell--head"><h3>Eddard Stark</h3></div>
  <div class="Rtable-cell">Has a sword named Ice</div>
  <div class="Rtable-cell">No direwolf</div>
  <div class="Rtable-cell  Rtable-cell--foot"><strong>Lord of Winterfell</strong></div>
  
  <button class="Accordion" role="tab" aria-selected="false">Jon</button>
  <div class="Rtable-cell  Rtable-cell--head"><h3>Jon Snow</h3></div>
  <div class="Rtable-cell">Has a sword named Longclaw</div>
  <div class="Rtable-cell">Direwolf: Ghost</div>
  <div class="Rtable-cell  Rtable-cell--foot"><strong>Knows nothing</strong></div>
  
  <button class="Accordion" role="tab" aria-selected="false">Arya</button>
  <div class="Rtable-cell  Rtable-cell--head"><h3>Arya Stark</h3></div>
  <div class="Rtable-cell">Has a sword named Needle</div>
  <div class="Rtable-cell">Direwolf: Nymeria</div>
  <div class="Rtable-cell  Rtable-cell--foot"><strong>No one</strong></div>

</div>


            
          
!

CSS

            
              @media all and (max-width: @breakpoint) { 
  .hiddenSmall {display: none; }
}


/* Tab Styling
==================================== */
@tabColour: darkcyan;

.Tablist {
  display: flex;
  flex-direction: row;
  margin-left: -@bw;
  @media all and (min-width: @breakpoint) { display: none; }
}
.Tab {
  padding: 0.6em 1em;
  margin: 0 @bw @bw 0;
  text-align: center;
  background-color: @tabColour;
  border: solid @bw @tabColour;
  border-bottom-width: 0;
  border-radius: 0.5em 0.5em 0 0;
  font-weight: bold;
  color: darken(@tabColour,20%);
  text-decoration: none;
  transition: background-color 0.1s;
  cursor: pointer;
  &:hover, &:focus {
    background-color: mix(white,@tabColour,10%);
    border-color: mix(white,@tabColour,10%);
    outline: none;
  }
  &[aria-selected="false"]:active {
    margin-top: 0.2em;
    padding-bottom: 0.4em;
  }
  &[aria-selected="true"] {
    background: mix(white,@tabColour,90%);
    cursor: default;
  }
}


/* Accordion Styling
==================================== */
@accordionColour: darkcyan;
@iconSize: 2em;

.Accordion {
  position: relative; top: -@bw; left: -@bw; //compensate for border offset
  width: 100%;
  margin: 0 0 0.5em 0;
  padding: 0.6em 0.6em 0.6em (@iconSize);
  border-radius: 0.5em;
  text-align: left;
  border: solid @bw mix(black,@accordionColour,15%);
  background-color: @accordionColour;
  font-weight: bold;
  color: darken(@accordionColour,20%);
  text-decoration: none;
  transition: background-color 0.1s;
  cursor: pointer;
  @media all and (min-width: @breakpoint) { display: none; }
  &:hover, &:focus {
    outline: none;
    filter: contrast(150%);
  }
  &[aria-selected="true"] {
    margin-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-width: 0;
    background: mix(white,@accordionColour,70%);
  }
  &:before {
    content: "+";
    position: absolute;
    top: 50%;
    left: 0.3em;
    margin-top: -(@iconSize/1.75);
    font-weight: normal;
    font-size: @iconSize;
    line-height: @iconSize;
    background-size: @iconSize @iconSize;
  }
  &[aria-selected="true"]:before {
    content: "-";
  }
}

.js-RtableTabs, .js-RtableAccordions {
  min-width: 240px;
}
            
          
!

JS

            
              (function ($) {
  "use strict";
  $.fn.responsiveTable = function() { 

    var toggleColumns = function($table) {
      var selectedControls = [];
      $table.find(".Accordion, .Tab").each( function() {
        selectedControls.push( $(this).attr("aria-selected") );
      });
      var cellCount = 0, colCount = 0;
      var setNum = $table.find(".Rtable-cell").length / Math.max( $table.find(".Tab").length, $table.find(".Accordion").length );
      $table.find(".Rtable-cell").each( function() {
        $(this).addClass("hiddenSmall");
        if( selectedControls[colCount] === "true" ) $(this).removeClass("hiddenSmall");
        cellCount++;
        if( cellCount % setNum === 0 ) colCount++; 
      });
    };
    $(this).each(function(){ toggleColumns($(this)); });

    $(this).find(".Tab").click( function() {
      $(this).attr("aria-selected","true").siblings().attr("aria-selected","false");
      toggleColumns( $(this).parents(".Rtable") );
    });

    $(this).find(".Accordion").click( function() {
      $(this).attr("aria-selected", $(this).attr("aria-selected") !== "true" );
      toggleColumns( $(this).parents(".Rtable") );
    });

  };
}(jQuery));


$(".js-RtableTabs, .js-RtableAccordions").responsiveTable();
            
          
!
999px

Console