Responsive table

source: http://codepen.io/geoffyuen/pen/FCBEg This one is an option since it has the filter capability: http://filamentgroup.github.io/tablesaw/demo/sort.html Another one: http://codepen.io/pixelchar/pen/rfuqK

by katalin_2003

HTML

<h1>RWD List to Table</h1>

<table class="rwd-table">
    <tr>
        <th>Name</th>
        <th>YTD Obj</th>
        <th>Actual YTD</th>
        <th>Margin Obj</th>
        <th>Actual Margin</th>
        <th>Margin %</th>
    </tr>
    <tr>
        <td data-th="Name">XXY</td>
        <td data-th="YTD Obj">3.700.000</td>
        <td data-th="Actual YTD">5.300.000</td>
        <td data-th="Margin Obj">$460,935,665</td>
        <td data-th="Actual Margin">1.300.000</td>
        <td data-th="Margin %">35%</td>
    </tr>
    <tr>
        <td data-th="Name">XYX</td>
        <td data-th="YTD Obj">1.450.000</td>
        <td data-th="Actual YTD">2.100.000</td>
        <td data-th="Margin Obj">$16,295,774</td>
        <td data-th="Actual Margin">700.000</td>
        <td data-th="Margin %">65%</td>
    </tr>
    <tr>
        <td data-th="Name">YXX</td>
        <td data-th="YTD Obj">1.900.000</td>
        <td data-th="Actual YTD">7.000.000</td>
        <td data-th="Margin Obj">$115,000,000</td>
        <td data-th="Actual Margin">4.500.000</td>
        <td data-th="Margin %">27%</td>
    </tr>
</table>
<p>&larr; Drag window (in editor or full page view) to see the effect. &rarr;</p>

CSS

@import"http://fonts.googleapis.com/css?family=Montserrat:300,400,700";
 .rwd-table {
    margin: 1em 0;
    min-width: 300px;
}
.rwd-table tr {
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
}
.rwd-table th {
    display: none;
}
.rwd-table td {
    display: block;
}
.rwd-table td:first-child {
    padding-top: .5em;
}
.rwd-table td:last-child {
    padding-bottom: .5em;
}
.rwd-table td:before {
    content: attr(data-th)": ";
    font-weight: bold;
    width: 6.5em;
    display: inline-block;
}
@media (min-width: 480px) {
    .rwd-table td:before {
        display: none;
    }
}
.rwd-table th, .rwd-table td {
    text-align: left;
}
@media (min-width: 480px) {
    .rwd-table th, .rwd-table td {
        display: table-cell;
        padding: .25em .5em;
    }
    .rwd-table th:first-child, .rwd-table td:first-child {
        padding-left: 0;
    }
    .rwd-table th:last-child, .rwd-table td:last-child {
        padding-right: 0;
    }
}
body {
    padding: 0 2em;
    font-family: Montserrat, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    color: #444;
    background: #eee;
}
h1 {
    font-weight: normal;
    letter-spacing: -1px;
    color: #34495E;
}
.rwd-table {
    background: #34495E;
    color: #fff;
    border-radius: .4em;
    overflow: hidden;
}
.rwd-table tr {
    border-color: #46627f;
}
.rwd-table th, .rwd-table td {
    margin: .5em 1em;
}
@media (min-width: 480px) {
    .rwd-table th, .rwd-table td {
        padding: 1em !important;
    }
}
.rwd-table th, .rwd-table td:before {
    color: #dd5;
}

JavaScript

/* SCSS */
/*
@import "compass/css3";

// More practical CSS...
// using mobile first method (IE8,7 requires respond.js polyfill https://github.com/scottjehl/Respond)

$breakpoint-alpha: 480px; // adjust to your needs

.rwd-table {
  margin: 1em 0;
  min-width: 300px; // adjust to your needs
  
  tr {
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
  }
  
  th {
    display: none; // for accessibility, use a visually hidden method here instead! Thanks, reddit!   
  }
  
  td {
    display: block; 
    
    &:first-child {
      padding-top: .5em;
    }
    &:last-child {
      padding-bottom: .5em;
    }

    &:before {
      content: attr(data-th)": "; // who knew you could do this? The internet, that's who.
      font-weight: bold;

      // optional stuff to make it look nicer
      width: 6.5em; // magic number :( adjust according to your own content
      display: inline-block;
      // end options
      
      @media (min-width: $breakpoint-alpha) {
        display: none;
      }
    }
  }
  
  th, td {
    text-align: left;
    
    @media (min-width: $breakpoint-alpha) {
      display: table-cell;
      padding: .25em .5em;
      
      &:first-child {
        padding-left: 0;
      }
      
      &:last-child {
        padding-right: 0;
      }
    }

  }
  
  
}


// presentational styling

@import 'http://fonts.googleapis.com/css?family=Montserrat:300,400,700';

body {
  padding: 0 2em;
  font-family: Montserrat, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  color: #444;
  background: #eee;
}

h1 {
  font-weight: normal;
  letter-spacing: -1px;
  color: #34495E;
}

.rwd-table {
  background: #34495E;
  color: #fff;
  border-radius: .4em;
  overflow: hidden;
  tr {
    border-color: lighten(#34495E, 10%);
  }
  th, td {
    margin: .5em 1em;
    @media (min-width: $breakpoint-alpha) { 
      padding: 1em !important; 
    }
  }
  th, td:before {
    color: #dd5;
  }
}
*/