"Responsive Data Tables"
Bootstrap 3.3.0 Snippet by AlexSemenov

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <label><a href="https://css-tricks.com/responsive-data-tables/">Link</a></label> <h2>Responsive Data Tables</h2> <table class="table-vertical"> <thead> <tr> <th>Title1</th> <th>Title2</th> <th>Title3</th> <th>Title4</th> <th>Title5</th> <th>Title6</th> <th>Title7</th> <th>Title8</th> <th>Title9</th> <th>Title10</th> </tr> </thead> <tbody> <tr> <td data-th="Title1">Value 1-1</td> <td data-th="Title2">Value 1-2</td> <td data-th="Title3">Value 1-3</td> <td data-th="Title4">Value 1-4</td> <td data-th="Title5">Value 1-5</td> <td data-th="Title6">Value 1-6</td> <td data-th="Title7">Value 1-7</td> <td data-th="Title8">Value 1-8</td> <td data-th="Title9">Value 1-9</td> <td data-th="Title10">Value 1-10</td> </tr> <tr> <td data-th="Title1">Value 1-1</td> <td data-th="Title2">Value 1-2</td> <td data-th="Title3">Value 1-3</td> <td data-th="Title4">Value 1-4</td> <td data-th="Title5">Value 1-5</td> <td data-th="Title6">Value 1-6</td> <td data-th="Title7">Value 1-7</td> <td data-th="Title8">Value 1-8</td> <td data-th="Title9">Value 1-9</td> <td data-th="Title10">Value 1-10</td> </tr> <tr> <td data-th="Title1">Value 1-1</td> <td data-th="Title2">Value 1-2</td> <td data-th="Title3">Value 1-3</td> <td data-th="Title4">Value 1-4</td> <td data-th="Title5">Value 1-5</td> <td data-th="Title6">Value 1-6</td> <td data-th="Title7">Value 1-7</td> <td data-th="Title8">Value 1-8</td> <td data-th="Title9">Value 1-9</td> <td data-th="Title10">Value 1-10</td> </tr> <tr> <td data-th="Title1">Value 1-1</td> <td data-th="Title2">Value 1-2</td> <td data-th="Title3">Value 1-3</td> <td data-th="Title4">Value 1-4</td> <td data-th="Title5">Value 1-5</td> <td data-th="Title6">Value 1-6</td> <td data-th="Title7">Value 1-7</td> <td data-th="Title8">Value 1-8</td> <td data-th="Title9">Value 1-9</td> <td data-th="Title10">Value 1-10</td> </tr> </tbody> </table> </div> </div>
/* Generic Styling, for Desktops/Laptops */ .table-vertical { width: 100%; height:auto; border-collapse: collapse; } /* Zebra striping */ .table-vertical>tbody>tr:nth-of-type(odd) { background: #f9f9f9; } .table-vertical>thead>tr>th { background: #fff; color: #000; font-weight: bold; } .table-vertical>tbody>tr>td, .table-vertical>thead>tr>th { padding: 6px; border-top: 1px solid #ddd; text-align: left; vertical-align: middle; } /* Max width before this PARTICULAR table gets nasty This query will take effect for any screen smaller than 760px and also iPads specifically. */ @media only screen and (max-width: 760px), (min-device-width: 768px) and (max-device-width: 1024px) { /* Force table to not be like tables anymore */ table, thead, tbody, th, td, tr { display: block; } /* Hide table headers (but not display: none;, for accessibility) */ .table-vertical thead tr { position: absolute; top: -9999px; left: -9999px; } .table-vertical>thead>tr, .table-vertical>tbody>tr{ border: 1px solid #ccc; } .table-vertical>thead>tr>td, .table-vertical>tbody>tr>td{ /* Behave like a "row" */ border: none; border-bottom: 1px solid #eee; position: relative; padding-left: 50%; } .table-vertical>tbody>tr>td:before { /* Now like a table header */ position: absolute; /* Top/left values mimic padding */ top: 6px; left: 6px; width: 45%; padding-right: 10px; white-space: nowrap; } /* Label the data */ .table-vertical>tbody>tr>td:before { content: attr(data-th); } }

Related: See More


Questions / Comments: