Pen Settings



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


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


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.


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.


                <h1>Responsive Tables: Collapse to tabs & accordions</h1>
  <li>Variant ways of collapsing layout tables on small screens</li>
  <li>This includes the basic table styles from <a href="" target="_blank">this Pen</a>.</li>


<h2>Tab collapse table</h2>
  <li>Each column collapses to tabs on small screens</li>
  <li>Note: The Tabs themselvs are not responsive and will break on a small enough screen with long enough tab wording</li>

<div class="Rtable Rtable--3cols Rtable--collapse js-RtableTabs">
  <div class="Tablist u-hiddenLarge" role="tablist"> 
    <button class="Tab" role="tab" aria-selected="true">Ned</button>
    <button class="Tab" role="tab" aria-selected="false">Jon</button>
    <button class="Tab" role="tab" aria-selected="false">Arya</button>

  <div style="order:0;" class="Rtable-cell Rtable-cell--head"><h3>Eddard Stark</h3></div>
  <div style="order:1;" class="Rtable-cell">Has a sword named Ice</div>
  <div style="order:2;" class="Rtable-cell">No direwolf</div>
  <div style="order:3;" class="Rtable-cell Rtable-cell--foot"><strong>Lord of Winterfell</strong></div>

  <div style="order:0;" class="Rtable-cell Rtable-cell--head"><h3>Jon Snow</h3></div>
  <div style="order:1;" class="Rtable-cell">Has a sword named Longclaw</div>
  <div style="order:2;" class="Rtable-cell">Direwolf: Ghost</div>
  <div style="order:3;" class="Rtable-cell Rtable-cell--foot"><strong>Knows nothing</strong></div>

  <div style="order:0;" class="Rtable-cell Rtable-cell--head"><h3>Arya Stark</h3></div>
  <div style="order:1;" class="Rtable-cell">Has a sword named Needle</div>
  <div style="order:2;" class="Rtable-cell">Direwolf: Nymeria</div>
  <div style="order:3;" class="Rtable-cell Rtable-cell--foot"><strong>No one</strong></div>



<h2>Accordion collapse table</h2>
  <li>Each column collapses to accordions on small screens</li>

<div class="Rtable Rtable--4cols Rtable--collapse js-RtableAccordions">
  <button class="Accordion u-hiddenLarge" 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 u-hiddenLarge" 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 u-hiddenLarge" 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>



<small>- end of examples -</small>


                /* Variables
==================================== */
@tabColour: darkcyan;
@accordionColour: darkcyan;

/* Tab Styling
==================================== */
.Tablist {
  display: flex;
  flex-direction: row;
  margin-left: -@bw;
.Tab {
  padding: @pad*0.6;
  margin: 0 @bw @bw 0;
  text-align: center;
  background-color: @tabColour;
  border: solid @bw @tabColour;
  border-bottom-width: 0;
  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: @pad*0.2;
    padding-bottom: @pad*0.4;
  &[aria-selected="true"] {
    background: mix(white,@tabColour,90%);
    cursor: default;

/* Accordion Styling
==================================== */
.Accordion {
  @iconSize: 20px;
  position: relative; top: -@bw; left: -@bw; //compensate for border offset
  width: 100%;
  width: ~"calc(100% + @{bw})";
  margin: 0 0 @pad*0.5 0;
  padding: @pad*0.6 @pad*0.6 @pad*0.6 (10px + @iconSize);
  border-radius: @pad*0.3;
  text-align: left;
  border: solid @bw mix(black,@accordionColour,15%);
  background-color: @accordionColour;
  text-decoration: none;
  transition: background-color 0.1s;
  cursor: pointer;
  &: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: 5px;
    width: @iconSize;
    height: @iconSize;
    margin-top: -(@iconSize/2);
    vertical-align: middle;
    text-align: center;
    font-size: @iconSize;
    line-height: @iconSize;
    background-size: @iconSize @iconSize;
  &[aria-selected="true"]:before {
    content: "-";



                (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() {
        if( selectedControls[colCount] === "true" ) $(this).removeClass("u-hiddenSmall");
        if( cellCount % setNum === 0 ) colCount++; 
    $(this).each(function(){ toggleColumns($(this)); });

    $(this).find(".Tab").click( function() {
      toggleColumns( $(this).parents(".Rtable") );

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


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