less/bootstrap/tables.less
[roojs1] / less / bootstrap / tables.less
1 //
2 // Tables
3 // --------------------------------------------------
4
5
6 table {
7   background-color: @table-bg;
8 }
9 caption {
10   padding-top: @table-cell-padding;
11   padding-bottom: @table-cell-padding;
12   color: @text-muted;
13   text-align: left;
14 }
15 th {
16   text-align: left;
17 }
18
19
20 // Baseline styles
21
22 .table {
23   width: 100%;
24   max-width: 100%;
25   margin-bottom: @line-height-computed;
26   border-bottom: 1px solid @table-border-color;
27   // Cells
28   > thead,
29   > tbody,
30   > tfoot {
31     > tr {
32       > th,
33       > td {
34         padding: @table-cell-padding;
35         line-height: @line-height-base;
36         vertical-align: top;
37         border-top: 1px solid @table-border-color;
38       }
39     }
40   }
41   // Bottom align for column headings
42   > thead > tr > th {
43     vertical-align: bottom;
44     border-bottom: 2px solid @table-border-color;
45   }
46   // Remove top border from thead by default
47   > caption + thead,
48   > colgroup + thead,
49   > thead:first-child {
50     > tr:first-child {
51       > th,
52       > td {
53         border-top: 0;
54       }
55     }
56   }
57   // Account for multiple tbody instances
58   > tbody + tbody {
59     border-top: 2px solid @table-border-color;
60   }
61   
62   // Nesting
63   .table {
64     background-color: @body-bg;
65   }
66 }
67
68
69 // Condensed table w/ half padding
70
71 .table-condensed {
72   > thead,
73   > tbody,
74   > tfoot {
75     > tr {
76       > th,
77       > td {
78         padding: @table-condensed-cell-padding;
79       }
80     }
81   }
82 }
83
84
85 // Bordered version
86 //
87 // Add borders all around the table and between all the columns.
88
89 .table-bordered {
90   border: 1px solid @table-border-color;
91   > thead,
92   > tbody,
93   > tfoot {
94     > tr {
95       > th,
96       > td {
97         border: 1px solid @table-border-color;
98       }
99     }
100   }
101   > thead > tr {
102     > th,
103     > td {
104       border-bottom-width: 2px;
105     }
106   }
107 }
108
109
110 // Zebra-striping
111 //
112 // Default zebra-stripe styles (alternating gray and transparent backgrounds)
113
114 .table-striped {
115   > tbody > tr:nth-of-type(odd) {
116     background-color: @table-bg-accent;
117   }
118 }
119
120
121 // Hover effect
122 //
123 // Placed here since it has to come after the potential zebra striping
124
125 .table-hover {
126   > tbody > tr:hover {
127     background-color: @table-bg-hover;
128   }
129 }
130
131
132 // Table cell sizing
133 //
134 // Reset default table behavior
135
136 table col[class*="col-"] {
137   position: static; // Prevent border hiding in Firefox and IE9-11 (see https://github.com/twbs/bootstrap/issues/11623)
138   float: none;
139   display: table-column;
140 }
141 table {
142   td,
143   th {
144     &[class*="col-"] {
145       position: static; // Prevent border hiding in Firefox and IE9-11 (see https://github.com/twbs/bootstrap/issues/11623)
146       float: none;
147       display: table-cell;
148     }
149   }
150 }
151
152
153 // Table backgrounds
154 //
155 // Exact selectors below required to override `.table-striped` and prevent
156 // inheritance to nested tables.
157
158 // Generate the contextual variants
159 .table-row-variant(active; @table-bg-active);
160 .table-row-variant(success; @state-success-bg);
161 .table-row-variant(info; @state-info-bg);
162 .table-row-variant(warning; @state-warning-bg);
163 .table-row-variant(danger; @state-danger-bg);
164
165
166 // Responsive tables
167 //
168 // Wrap your tables in `.table-responsive` and we'll make them mobile friendly
169 // by enabling horizontal scrolling. Only applies <768px. Everything above that
170 // will display normally.
171
172 .table-responsive {
173   overflow-x: auto;
174   min-height: 0.01%; // Workaround for IE9 bug (see https://github.com/twbs/bootstrap/issues/14837)
175
176   @media screen and (max-width: @screen-xs-max) {
177     width: 100%;
178     margin-bottom: (@line-height-computed * 0.75);
179     overflow-y: hidden;
180     -ms-overflow-style: -ms-autohiding-scrollbar;
181     border: 1px solid @table-border-color;
182
183     // Tighten up spacing
184     > .table {
185       margin-bottom: 0;
186
187       // Ensure the content doesn't wrap
188       > thead,
189       > tbody,
190       > tfoot {
191         > tr {
192           > th,
193           > td {
194             white-space: nowrap;
195           }
196         }
197       }
198     }
199
200     // Special overrides for the bordered tables
201     > .table-bordered {
202       border: 0;
203
204       // Nuke the appropriate borders so that the parent can handle them
205       > thead,
206       > tbody,
207       > tfoot {
208         > tr {
209           > th:first-child,
210           > td:first-child {
211             border-left: 0;
212           }
213           > th:last-child,
214           > td:last-child {
215             border-right: 0;
216           }
217         }
218       }
219
220       // Only nuke the last row's bottom-border in `tbody` and `tfoot` since
221       // chances are there will be only one `tr` in a `thead` and that would
222       // remove the border altogether.
223       > tbody,
224       > tfoot {
225         > tr:last-child {
226           > th,
227           > td {
228             border-bottom: 0;
229           }
230         }
231       }
232
233     }
234   }
235 }