1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05:00

rewrite all table styles to remove in selectors

This commit is contained in:
Mark Otto 2014-12-18 22:59:47 -08:00
parent 83b3252404
commit 547f16b58e
8 changed files with 108 additions and 238 deletions

View file

@ -1722,39 +1722,42 @@ th {
max-width: 100%; max-width: 100%;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
.table > thead > tr > th, .table > thead > tr > td, .table > tbody > tr > th, .table > tbody > tr > td, .table > tfoot > tr > th, .table > tfoot > tr > td { .table th, .table td {
padding: .75rem; padding: .75rem;
line-height: 1.5; line-height: 1.5;
vertical-align: top; vertical-align: top;
border-top: 1px solid #eceeef; border-top: 1px solid #eceeef;
} }
.table > thead > tr > th { .table thead th {
vertical-align: bottom; vertical-align: bottom;
border-bottom: 2px solid #eceeef; border-bottom: 2px solid #eceeef;
} }
.table > tbody + tbody { .table tbody + tbody {
border-top: 2px solid #eceeef; border-top: 2px solid #eceeef;
} }
.table .table {
background-color: #fff;
}
.table-sm > thead > tr > th, .table-sm > thead > tr > td, .table-sm > tbody > tr > th, .table-sm > tbody > tr > td, .table-sm > tfoot > tr > th, .table-sm > tfoot > tr > td { .table-sm th, .table-sm td {
padding: .3rem; padding: .3rem;
} }
.table-bordered { .table-bordered {
border: 1px solid #eceeef; border: 1px solid #eceeef;
} }
.table-bordered > thead > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > th, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > th, .table-bordered > tfoot > tr > td { .table-bordered th, .table-bordered td {
border: 1px solid #eceeef; border: 1px solid #eceeef;
} }
.table-bordered > thead > tr > th, .table-bordered > thead > tr > td { .table-bordered thead th, .table-bordered thead td {
border-bottom-width: 2px; border-bottom-width: 2px;
} }
.table-striped > tbody > tr:nth-child(odd) { .table-striped tbody tr:nth-child(odd) {
background-color: #f9f9f9; background-color: #f9f9f9;
} }
.table-hover > tbody > tr:hover { .table-hover tbody tr:hover {
background-color: #f5f5f5; background-color: #f5f5f5;
} }
@ -1811,43 +1814,17 @@ table td[class*="col-"], table th[class*="col-"] {
} }
.table-responsive { .table-responsive {
min-height: .01%; display: block;
width: 100%;
overflow-x: auto; overflow-x: auto;
} }
@media screen and (max-width: 33.9em) {
.table-responsive {
width: 100%;
margin-bottom: 1rem;
overflow-y: hidden;
-ms-overflow-style: -ms-autohiding-scrollbar;
border: 1px solid #eceeef;
}
.table-responsive > .table {
margin-bottom: 0;
}
.table-responsive > .table > thead > tr > th, .table-responsive > .table > thead > tr > td, .table-responsive > .table > tbody > tr > th, .table-responsive > .table > tbody > tr > td, .table-responsive > .table > tfoot > tr > th, .table-responsive > .table > tfoot > tr > td {
white-space: nowrap;
}
.table-responsive > .table-bordered {
border: 0;
}
.table-responsive > .table-bordered > thead > tr > th:first-child, .table-responsive > .table-bordered > thead > tr > td:first-child, .table-responsive > .table-bordered > tbody > tr > th:first-child, .table-responsive > .table-bordered > tbody > tr > td:first-child, .table-responsive > .table-bordered > tfoot > tr > th:first-child, .table-responsive > .table-bordered > tfoot > tr > td:first-child {
border-left: 0;
}
.table-responsive > .table-bordered > thead > tr > th:last-child, .table-responsive > .table-bordered > thead > tr > td:last-child, .table-responsive > .table-bordered > tbody > tr > th:last-child, .table-responsive > .table-bordered > tbody > tr > td:last-child, .table-responsive > .table-bordered > tfoot > tr > th:last-child, .table-responsive > .table-bordered > tfoot > tr > td:last-child {
border-right: 0;
}
.table-responsive > .table-bordered > tbody > tr:last-child > th, .table-responsive > .table-bordered > tbody > tr:last-child > td, .table-responsive > .table-bordered > tfoot > tr:last-child > th, .table-responsive > .table-bordered > tfoot > tr:last-child > td {
border-bottom: 0;
}
}
.table > .thead-inverse > tr > th { .thead-inverse th {
color: #fff; color: #fff;
background-color: #373a3c; background-color: #373a3c;
} }
.table > .thead-default > tr > th { .thead-default th {
color: #55595c; color: #55595c;
background-color: #eceeef; background-color: #eceeef;
} }
@ -1859,7 +1836,7 @@ table td[class*="col-"], table th[class*="col-"] {
.table-inverse.table-bordered { .table-inverse.table-bordered {
border: 0; border: 0;
} }
.table-inverse > thead > tr > th, .table-inverse > thead > tr > td, .table-inverse > tbody > tr > th, .table-inverse > tbody > tr > td { .table-inverse th, .table-inverse td {
border-color: #55595c; border-color: #55595c;
} }
@ -1870,14 +1847,14 @@ table td[class*="col-"], table th[class*="col-"] {
display: block; display: block;
white-space: nowrap; white-space: nowrap;
} }
.table-reflow > thead > tr > th, .table-reflow > thead > tr > td, .table-reflow > tbody > tr > th, .table-reflow > tbody > tr > td, .table-reflow > tfoot > tr > th, .table-reflow > tfoot > tr > td { .table-reflow th, .table-reflow td {
border-top: 1px solid #eceeef; border-top: 1px solid #eceeef;
border-left: 1px solid #eceeef; border-left: 1px solid #eceeef;
} }
.table-reflow > thead > tr > th:last-child, .table-reflow > thead > tr > td:last-child, .table-reflow > tbody > tr > th:last-child, .table-reflow > tbody > tr > td:last-child, .table-reflow > tfoot > tr > th:last-child, .table-reflow > tfoot > tr > td:last-child { .table-reflow th:last-child, .table-reflow td:last-child {
border-right: 1px solid #eceeef; border-right: 1px solid #eceeef;
} }
.table-reflow > thead:last-child > tr:last-child > th, .table-reflow > thead:last-child > tr:last-child > td, .table-reflow > tbody:last-child > tr:last-child > th, .table-reflow > tbody:last-child > tr:last-child > td, .table-reflow > tfoot:last-child > tr:last-child > th, .table-reflow > tfoot:last-child > tr:last-child > td { .table-reflow thead:last-child tr:last-child th, .table-reflow thead:last-child tr:last-child td, .table-reflow tbody:last-child tr:last-child th, .table-reflow tbody:last-child tr:last-child td, .table-reflow tfoot:last-child tr:last-child th, .table-reflow tfoot:last-child tr:last-child td {
border-bottom: 1px solid #eceeef; border-bottom: 1px solid #eceeef;
} }
.table-reflow tr { .table-reflow tr {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -193,13 +193,13 @@ Add `.table-bordered` for borders on all sides of the table and cells.
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<th scope="row">1</tg> <th scope="row">1</th>
<td>Mark</td> <td>Mark</td>
<td>Otto</td> <td>Otto</td>
<td>@mdo</td> <td>@mdo</td>
</tr> </tr>
<tr> <tr>
<th scope="row">2</tg> <th scope="row">2</th>
<td>Mark</td> <td>Mark</td>
<td>Otto</td> <td>Otto</td>
<td>@TwBootstrap</td> <td>@TwBootstrap</td>

View file

@ -1722,39 +1722,42 @@ th {
max-width: 100%; max-width: 100%;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
.table > thead > tr > th, .table > thead > tr > td, .table > tbody > tr > th, .table > tbody > tr > td, .table > tfoot > tr > th, .table > tfoot > tr > td { .table th, .table td {
padding: .75rem; padding: .75rem;
line-height: 1.5; line-height: 1.5;
vertical-align: top; vertical-align: top;
border-top: 1px solid #eceeef; border-top: 1px solid #eceeef;
} }
.table > thead > tr > th { .table thead th {
vertical-align: bottom; vertical-align: bottom;
border-bottom: 2px solid #eceeef; border-bottom: 2px solid #eceeef;
} }
.table > tbody + tbody { .table tbody + tbody {
border-top: 2px solid #eceeef; border-top: 2px solid #eceeef;
} }
.table .table {
background-color: #fff;
}
.table-sm > thead > tr > th, .table-sm > thead > tr > td, .table-sm > tbody > tr > th, .table-sm > tbody > tr > td, .table-sm > tfoot > tr > th, .table-sm > tfoot > tr > td { .table-sm th, .table-sm td {
padding: .3rem; padding: .3rem;
} }
.table-bordered { .table-bordered {
border: 1px solid #eceeef; border: 1px solid #eceeef;
} }
.table-bordered > thead > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > th, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > th, .table-bordered > tfoot > tr > td { .table-bordered th, .table-bordered td {
border: 1px solid #eceeef; border: 1px solid #eceeef;
} }
.table-bordered > thead > tr > th, .table-bordered > thead > tr > td { .table-bordered thead th, .table-bordered thead td {
border-bottom-width: 2px; border-bottom-width: 2px;
} }
.table-striped > tbody > tr:nth-child(odd) { .table-striped tbody tr:nth-child(odd) {
background-color: #f9f9f9; background-color: #f9f9f9;
} }
.table-hover > tbody > tr:hover { .table-hover tbody tr:hover {
background-color: #f5f5f5; background-color: #f5f5f5;
} }
@ -1811,43 +1814,17 @@ table td[class*="col-"], table th[class*="col-"] {
} }
.table-responsive { .table-responsive {
min-height: .01%; display: block;
width: 100%;
overflow-x: auto; overflow-x: auto;
} }
@media screen and (max-width: 33.9em) {
.table-responsive {
width: 100%;
margin-bottom: 1rem;
overflow-y: hidden;
-ms-overflow-style: -ms-autohiding-scrollbar;
border: 1px solid #eceeef;
}
.table-responsive > .table {
margin-bottom: 0;
}
.table-responsive > .table > thead > tr > th, .table-responsive > .table > thead > tr > td, .table-responsive > .table > tbody > tr > th, .table-responsive > .table > tbody > tr > td, .table-responsive > .table > tfoot > tr > th, .table-responsive > .table > tfoot > tr > td {
white-space: nowrap;
}
.table-responsive > .table-bordered {
border: 0;
}
.table-responsive > .table-bordered > thead > tr > th:first-child, .table-responsive > .table-bordered > thead > tr > td:first-child, .table-responsive > .table-bordered > tbody > tr > th:first-child, .table-responsive > .table-bordered > tbody > tr > td:first-child, .table-responsive > .table-bordered > tfoot > tr > th:first-child, .table-responsive > .table-bordered > tfoot > tr > td:first-child {
border-left: 0;
}
.table-responsive > .table-bordered > thead > tr > th:last-child, .table-responsive > .table-bordered > thead > tr > td:last-child, .table-responsive > .table-bordered > tbody > tr > th:last-child, .table-responsive > .table-bordered > tbody > tr > td:last-child, .table-responsive > .table-bordered > tfoot > tr > th:last-child, .table-responsive > .table-bordered > tfoot > tr > td:last-child {
border-right: 0;
}
.table-responsive > .table-bordered > tbody > tr:last-child > th, .table-responsive > .table-bordered > tbody > tr:last-child > td, .table-responsive > .table-bordered > tfoot > tr:last-child > th, .table-responsive > .table-bordered > tfoot > tr:last-child > td {
border-bottom: 0;
}
}
.table > .thead-inverse > tr > th { .thead-inverse th {
color: #fff; color: #fff;
background-color: #373a3c; background-color: #373a3c;
} }
.table > .thead-default > tr > th { .thead-default th {
color: #55595c; color: #55595c;
background-color: #eceeef; background-color: #eceeef;
} }
@ -1859,7 +1836,7 @@ table td[class*="col-"], table th[class*="col-"] {
.table-inverse.table-bordered { .table-inverse.table-bordered {
border: 0; border: 0;
} }
.table-inverse > thead > tr > th, .table-inverse > thead > tr > td, .table-inverse > tbody > tr > th, .table-inverse > tbody > tr > td { .table-inverse th, .table-inverse td {
border-color: #55595c; border-color: #55595c;
} }
@ -1870,14 +1847,14 @@ table td[class*="col-"], table th[class*="col-"] {
display: block; display: block;
white-space: nowrap; white-space: nowrap;
} }
.table-reflow > thead > tr > th, .table-reflow > thead > tr > td, .table-reflow > tbody > tr > th, .table-reflow > tbody > tr > td, .table-reflow > tfoot > tr > th, .table-reflow > tfoot > tr > td { .table-reflow th, .table-reflow td {
border-top: 1px solid #eceeef; border-top: 1px solid #eceeef;
border-left: 1px solid #eceeef; border-left: 1px solid #eceeef;
} }
.table-reflow > thead > tr > th:last-child, .table-reflow > thead > tr > td:last-child, .table-reflow > tbody > tr > th:last-child, .table-reflow > tbody > tr > td:last-child, .table-reflow > tfoot > tr > th:last-child, .table-reflow > tfoot > tr > td:last-child { .table-reflow th:last-child, .table-reflow td:last-child {
border-right: 1px solid #eceeef; border-right: 1px solid #eceeef;
} }
.table-reflow > thead:last-child > tr:last-child > th, .table-reflow > thead:last-child > tr:last-child > td, .table-reflow > tbody:last-child > tr:last-child > th, .table-reflow > tbody:last-child > tr:last-child > td, .table-reflow > tfoot:last-child > tr:last-child > th, .table-reflow > tfoot:last-child > tr:last-child > td { .table-reflow thead:last-child tr:last-child th, .table-reflow thead:last-child tr:last-child td, .table-reflow tbody:last-child tr:last-child th, .table-reflow tbody:last-child tr:last-child td, .table-reflow tfoot:last-child tr:last-child th, .table-reflow tfoot:last-child tr:last-child td {
border-bottom: 1px solid #eceeef; border-bottom: 1px solid #eceeef;
} }
.table-reflow tr { .table-reflow tr {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,84 +1,65 @@
// //
// Tables // Reset tabular elements
// -------------------------------------------------- //
table { table {
background-color: $table-bg; background-color: $table-bg;
} }
caption { caption {
padding-top: $table-cell-padding; padding-top: $table-cell-padding;
padding-bottom: $table-cell-padding; padding-bottom: $table-cell-padding;
color: $text-muted; color: $text-muted;
text-align: left; text-align: left;
} }
th { th {
text-align: left; text-align: left;
} }
// Baseline styles //
// Basic tables
//
.table { .table {
width: 100%; width: 100%;
max-width: 100%; max-width: 100%;
margin-bottom: $spacer; margin-bottom: $spacer;
// Cells th,
> thead, td {
> tbody,
> tfoot {
> tr {
> th,
> td {
padding: $table-cell-padding; padding: $table-cell-padding;
line-height: $line-height-base; line-height: $line-height-base;
vertical-align: top; vertical-align: top;
border-top: 1px solid $table-border-color; border-top: 1px solid $table-border-color;
} }
}
} thead th {
// Bottom align for column headings
> thead > tr > th {
vertical-align: bottom; vertical-align: bottom;
border-bottom: 2px solid $table-border-color; border-bottom: 2px solid $table-border-color;
} }
// Remove top border from thead by default
// > caption + thead, tbody + tbody {
// > colgroup + thead,
// > thead:first-child {
// > tr:first-child {
// > th,
// > td {
// border-top: 0;
// }
// }
// }
// Account for multiple tbody instances
> tbody + tbody {
border-top: 2px solid $table-border-color; border-top: 2px solid $table-border-color;
} }
// Nesting .table {
// .table { background-color: $body-bg;
// background-color: $body-bg; }
// }
} }
//
// Condensed table w/ half padding // Condensed table w/ half padding
//
.table-sm { .table-sm {
> thead, th,
> tbody, td {
> tfoot {
> tr {
> th,
> td {
padding: $table-sm-cell-padding; padding: $table-sm-cell-padding;
} }
} }
}
}
// Bordered version // Bordered version
@ -87,19 +68,15 @@ th {
.table-bordered { .table-bordered {
border: 1px solid $table-border-color; border: 1px solid $table-border-color;
> thead,
> tbody, th,
> tfoot { td {
> tr {
> th,
> td {
border: 1px solid $table-border-color; border: 1px solid $table-border-color;
} }
}
} thead {
> thead > tr { th,
> th, td {
> td {
border-bottom-width: 2px; border-bottom-width: 2px;
} }
} }
@ -111,7 +88,7 @@ th {
// Default zebra-stripe styles (alternating gray and transparent backgrounds) // Default zebra-stripe styles (alternating gray and transparent backgrounds)
.table-striped { .table-striped {
> tbody > tr:nth-child(odd) { tbody tr:nth-child(odd) {
background-color: $table-bg-accent; background-color: $table-bg-accent;
} }
} }
@ -122,7 +99,7 @@ th {
// Placed here since it has to come after the potential zebra striping // Placed here since it has to come after the potential zebra striping
.table-hover { .table-hover {
> tbody > tr:hover { tbody tr:hover {
background-color: $table-bg-hover; background-color: $table-bg-hover;
} }
} }
@ -170,79 +147,26 @@ table {
// will display normally. // will display normally.
.table-responsive { .table-responsive {
min-height: 0.01%; // Workaround for IE9 bug (see https://github.com/twbs/bootstrap/issues/14837) display: block;
width: 100%;
overflow-x: auto; overflow-x: auto;
@media screen and (max-width: $screen-xs-max) { // Todo: find out if we need this still.
width: 100%; //
margin-bottom: $spacer; // border: 1px solid $table-border-color;
overflow-y: hidden; // -ms-overflow-style: -ms-autohiding-scrollbar;
border: 1px solid $table-border-color; // min-height: 0.01%; // Workaround for IE9 bug (see https://github.com/twbs/bootstrap/issues/14837)
-ms-overflow-style: -ms-autohiding-scrollbar;
// Tighten up spacing
> .table {
margin-bottom: 0;
// Ensure the content doesn't wrap
> thead,
> tbody,
> tfoot {
> tr {
> th,
> td {
white-space: nowrap;
}
}
}
}
// Special overrides for the bordered tables
> .table-bordered {
border: 0;
// Nuke the appropriate borders so that the parent can handle them
> thead,
> tbody,
> tfoot {
> tr {
> th:first-child,
> td:first-child {
border-left: 0;
}
> th:last-child,
> td:last-child {
border-right: 0;
}
}
}
// Only nuke the last row's bottom-border in `tbody` and `tfoot` since
// chances are there will be only one `tr` in a `thead` and that would
// remove the border altogether.
> tbody,
> tfoot {
> tr:last-child {
> th,
> td {
border-bottom: 0;
}
}
}
}
}
} }
.table > .thead-inverse { .thead-inverse {
> tr > th { th {
color: #fff; color: #fff;
background-color: $gray-dark; background-color: $gray-dark;
} }
} }
.table > .thead-default { .thead-default {
> tr > th { th {
color: $gray; color: $gray;
background-color: $gray-lighter; background-color: $gray-lighter;
} }
@ -256,20 +180,14 @@ table {
border: 0; border: 0;
} }
> thead, th,
> tbody { td {
> tr {
> th,
> td {
border-color: $gray; border-color: $gray;
} }
} }
}
}
.table-reflow { .table-reflow {
thead { thead {
float: left; float: left;
} }
@ -279,12 +197,8 @@ table {
white-space: nowrap; white-space: nowrap;
} }
> thead, th,
> tbody, td {
> tfoot {
> tr {
> th,
> td {
border-top: 1px solid $table-border-color; border-top: 1px solid $table-border-color;
border-left: 1px solid $table-border-color; border-left: 1px solid $table-border-color;
@ -292,12 +206,14 @@ table {
border-right: 1px solid $table-border-color; border-right: 1px solid $table-border-color;
} }
} }
}
thead,
tbody,
tfoot {
&:last-child { &:last-child {
> tr:last-child { tr:last-child {
> th, th,
> td { td {
border-bottom: 1px solid $table-border-color; border-bottom: 1px solid $table-border-color;
} }
} }