cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <header>
  <h1>Responsive table experiment (improved)</h1>
  <p>Resize your browser to see the table adapt responsively through screensizes. No JS required. In this version we are using a max-width breakpoint which helps reduce the CSS overhead.</p>
</header>

<!-- Tables begin -->
<table class="sheru-cp-section table">
  <thead class="table__head">
    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="col">Name</th>
      <th class="table__cell table__cell--head" scope="col">Version</th>
      <th class="table__cell table__cell--head" scope="col">Release date</th>
      <th class="table__cell table__cell--head" scope="col">Release #</th>
    </tr>
  </thead>
  <tbody class="table__body">
    
    <tr class="table__row">
      <th class="table__cell table__cell--head table__cell--spanned" colspan="4">
        macOS
      </th>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="row" data-title="Name">
        Sierra
      </th>
      <td class="table__cell" data-title="Version">
        10.12
      </td>
      <td class="table__cell" data-title="Release date">
        2016-09-20
      </td>
      <td class="table__cell" data-title="Release #">
        14
      </td>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head table__cell--spanned" colspan="4">
        OS X
      </th>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="row" data-title="Name">
        El Capitan
      </th>
      <td class="table__cell" data-title="Version">
        10.11
      </td>
      <td class="table__cell" data-title="Release date">
        2015-09-30
      </td>
      <td class="table__cell" data-title="Release #">
        13
      </td>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="row" data-title="Name">
        Yosemite
      </th>
      <td class="table__cell" data-title="Version">
        10.10
      </td>
      <td class="table__cell" data-title="Release date">
        2014-10-16
      </td>
      <td class="table__cell" data-title="Release #">
        12
      </td>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="row" data-title="Name">
        Mavericks
      </th>
      <td class="table__cell" data-title="Version">
        10.9
      </td>
      <td class="table__cell" data-title="Release date">
        2013-10-22
      </td>
      <td class="table__cell" data-title="Release #">
        11
      </td>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="row" data-title="Name">
        Mountain Lion
      </th>
      <td class="table__cell" data-title="Version">
        10.8
      </td>
      <td class="table__cell" data-title="Release date">
        2012-07-25
      </td>
      <td class="table__cell" data-title="Release #">
        10
      </td>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="row" data-title="Name">
        Lion
      </th>
      <td class="table__cell" data-title="Version">
        10.7
      </td>
      <td class="table__cell" data-title="Release date">
        2011-07-20
      </td>
      <td class="table__cell" data-title="Release #">
        9
      </td>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="row" data-title="Name">
        Snow Leopard
      </th>
      <td class="table__cell" data-title="Version">
        10.6
      </td>
      <td class="table__cell" data-title="Release date">
        2009-08-28
      </td>
      <td class="table__cell" data-title="Release #">
        8
      </td>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="row" data-title="Name">
        Leopard
      </th>
      <td class="table__cell" data-title="Version">
        10.5
      </td>
      <td class="table__cell" data-title="Release date">
        2007-10-26
      </td>
      <td class="table__cell" data-title="Release #">
        7
      </td>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="row" data-title="Name">
        Tiger
      </th>
      <td class="table__cell" data-title="Version">
        10.4
      </td>
      <td class="table__cell" data-title="Release date">
        2005-04-29
      </td>
      <td class="table__cell" data-title="Release #">
        6
      </td>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="row" data-title="Name">
        Panther
      </th>
      <td class="table__cell" data-title="Version">
        10.3
      </td>
      <td class="table__cell" data-title="Release date">
        2003-10-24
      </td>
      <td class="table__cell" data-title="Release #">
        5
      </td>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="row" data-title="Name">
        Jaguar
      </th>
      <td class="table__cell" data-title="Version">
        10.2
      </td>
      <td class="table__cell" data-title="Release date">
        2002-08-23
      </td>
      <td class="table__cell" data-title="Release #">
        4
      </td>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="row" data-title="Name">
        Puma
      </th>
      <td class="table__cell" data-title="Version">
        10.1
      </td>
      <td class="table__cell" data-title="Release date">
        2001-09-25
      </td>
      <td class="table__cell" data-title="Release #">
        3
      </td>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="row" data-title="Name">
        Cheetah
      </th>
      <td class="table__cell" data-title="Version">
        10.0
      </td>
      <td class="table__cell" data-title="Release date">
        2001-03-24
      </td>
      <td class="table__cell" data-title="Release #">
        2
      </td>
    </tr>

    <tr class="table__row">
      <th class="table__cell table__cell--head" scope="row" data-title="Name">
        Kodiak
      </th>
      <td class="table__cell" data-title="Version">
        0
      </td>
      <td class="table__cell" data-title="Release date">
        2000-09-13
      </td>
      <td class="table__cell" data-title="Release #">
        1
      </td>
    </tr>

  </tbody>
</table>

            
          
!
            
              // Mixing to make breakpoints a little easier. Can be expanded with any breakpoints as needed.
@mixin breakpoint-max($point) {
  @media (max-width: 48rem)  { @content ; }
}

// Namespace so that it's easy to use your own table namespace
$namespace: "table";
$table-wrapped-header: 120px;
$table-cell-padding: 6px;
$color-table: #ae8f13;
$color-table-body: #dbc674;

.#{$namespace} {

  transition: 0.5s;
  padding-bottom: 0;  
  max-width: 900px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  border: 2px solid darken($color-table-body, 70%);
  font-family: 'Dosis', sans-serif;
  
  @include breakpoint-max(medium) {
    width: 100%;
  }

  &__head {
    color: white;
    
    @include breakpoint-max(medium) { 
      display: none;
      visibility: hidden;
    }
  }

  &__body,
  &__row,
  &__cell {
    border: 0;
    padding: 0;
    text-align: left;
    white-space: normal;
    
    // Mobile
    @include breakpoint-max(medium) {
      display: block;
    }
  }
  
  &__row {
    margin-bottom: 10px;
    background-color: darken($color-table-body, 5%);
    
    &:nth-child(even) {
      background-color: $color-table-body;
    }
  }
  
  &__cell {
    padding: $table-cell-padding;
    transition: 1s;
    
    // Cell in table heading (desktop only)
    .table__head & {
      padding: 20px;
      text-shadow: 0 1px 0 darken($color-table, 90%);
      text-align: center;
      font-size: 1.35rem;
      background: $color-table;
      box-shadow: inset 0px 1px 2px lighten($color-table, 20%);
      border: 1px solid darken($color-table, 20%);
    }
    
    // Cell in table body
    .#{$namespace}__body & {
      text-align: left;
      padding: 16px;
      border: 1px solid darken($color-table-body, 15%);
      box-shadow: inset 0px 1px 2px lighten($color-table-body, 20%);
    }
  
    &[data-title]:before {   

      // Mobile
      @include breakpoint-max(medium) {
        display: inline-block;
        min-width: $table-wrapped-header;
        content: attr(data-title) ":";
        font-weight: bold;
      }
    }

    &:empty {
      display: none;
    }

    &--spanned {
      font-size: 1.2rem;
      font-weight: bold;
    }

  }
}

// Cosmetics
body {
  background-color: $color-table;
}

header {
  padding: 40px 20px 60px;
  
  h1 {
    margin-bottom: 20px;
    font-size: 20px;
  }
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console