Skip to content

Instantly share code, notes, and snippets.

@manuelpette
Created February 8, 2017 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manuelpette/94be3d6c92a900c3809a3a0f208a07fb to your computer and use it in GitHub Desktop.
Save manuelpette/94be3d6c92a900c3809a3a0f208a07fb to your computer and use it in GitHub Desktop.
less to stack tables
.table {
background-color: #fff;
> thead {
background-color: transparent;
border-top: 1px solid rgba(0, 0, 0, 0.1);
> tr > th {
padding: 10px;
font-weight: 600;
background-color: #f1f1f1;
}
}
}
.table-striped > tbody > tr:nth-of-type(odd) {
background-color: @table-bg-accent;
}
.table-hover > tbody > tr:hover {
background-color: @table-bg-hover;
}
.table-stacked.table-bordered > tbody > tr > td {
@media (max-width: @screen-sm-max) {
padding-left: 15px;
line-height: 30px;
border: none;
border-top: 1px solid rgba(0, 0, 0, 0.1);
}
}
.table-stacked {
tbody, tr, th, td {
display: block;
white-space: normal;
}
td[data-title]:before {
content: attr(data-title);
float: left;
font-weight: 600;
@media (min-width: @screen-md-min) {
content: none;
}
}
@media (max-width: @screen-sm-max) {
> thead, > tbody > tr > th {
position: absolute;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
padding: 0;
border: 0;
height: 1px;
width: 1px;
overflow: hidden;
}
> tbody > tr > th {
text-align: center;
}
tbody, tr, th, td {
text-align: right;
}
tr {
margin-top: 20px;
&:first-child {
margin-top: 0;
}
}
td {
min-height: 47px;
}
}
@media (min-width: @screen-md-min) {
tr {
display: table-row;
}
th, td {
display: table-cell;
}
tbody {
display: table-row-group;
}
}
@media (max-width: @screen-md-max) {
> tbody > tr:first-child > td {
border-top-width: 1px;
}
}
}
table .dropdown-menu-right {
@media (max-width: @screen-sm-max) {
right: auto;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment