Created
April 4, 2016 06:31
-
-
Save RemeJuan/762ada2051bdc6269284b81ba6cb19f0 to your computer and use it in GitHub Desktop.
Better responsive table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@media only screen and (max-width: 800px) { | |
.enhanced-responsive-table { | |
table, thead, tbody, th, td, tr { | |
display: block; | |
} | |
thead tr { | |
position: absolute; | |
top: -9999px; | |
left: -9999px; | |
} | |
tr { | |
border: 1px solid #ccc; | |
} | |
td { | |
border: none; | |
border-bottom: 1px solid #eee; | |
position: relative; | |
padding-left: 50%; | |
white-space: normal; | |
text-align:left; | |
} | |
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; | |
text-align:left; | |
font-weight: bold; | |
} | |
td:before { | |
content: attr(data-title); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="enhanced-responsive-table"> | |
<table class="col-md-12 table-bordered table-striped table-condensed cf"> | |
<thead class="cf"> | |
<tr> | |
<th class="col-md-4">Head 1</th> | |
<th class="col-md-4">Head 2</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td data-title="Head 1">Column</td> | |
<td data-title="Head 2">Column</td> | |
</tr> | |
</tbody> | |
</table> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment