Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"Responsive Data Tables"
Bootstrap 3.3.0 Snippet by
AlexSemenov
3.3.0
table
responsive
Preview
HTML
CSS
View Full Screen
Fork
Fork this
17.6K
 
7 Fav
Post to Facebook
Tweet this
<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); } }
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76