_tables.less 5.59 KB
Newer Older
1
//
2
3
// Tables
// --------------------------------------------------
Jacob Thornton's avatar
Jacob Thornton committed
4

5

6
table {
7
  background-color: @table-bg;
8
}
9
10
11
12
13
14
caption {
  padding-top: @table-cell-padding;
  padding-bottom: @table-cell-padding;
  color: @text-muted;
  text-align: left;
}
15
16
17
th {
  text-align: left;
}
18
19


20
// Baseline styles
Jacob Thornton's avatar
Jacob Thornton committed
21

22
.table {
Jacob Thornton's avatar
Jacob Thornton committed
23
  width: 100%;
24
  max-width: 100%;
25
  margin-bottom: @line-height-computed;
26
  // Cells
27
28
29
  > thead,
  > tbody,
  > tfoot {
30
31
32
    > tr {
      > th,
      > td {
33
        padding: @table-cell-padding;
34
35
36
37
38
        line-height: @line-height-base;
        vertical-align: top;
        border-top: 1px solid @table-border-color;
      }
    }
39
  }
40
  // Bottom align for column headings
41
  > thead > tr > th {
42
    vertical-align: bottom;
43
    border-bottom: 2px solid @table-border-color;
44
45
  }
  // Remove top border from thead by default
46
47
48
49
50
51
52
53
54
55
//  > caption + thead,
//  > colgroup + thead,
//  > thead:first-child {
//    > tr:first-child {
//      > th,
//      > td {
//        border-top: 0;
//      }
//    }
//  }
56
  // Account for multiple tbody instances
57
  > tbody + tbody {
58
    border-top: 2px solid @table-border-color;
59
  }
Mark Otto's avatar
Mark Otto committed
60
61

  // Nesting
62
63
64
//  .table {
//    background-color: @body-bg;
//  }
65
66
}

67

68
// Condensed table w/ half padding
69

70
.table-sm {
71
72
73
  > thead,
  > tbody,
  > tfoot {
74
75
76
    > tr {
      > th,
      > td {
77
        padding: @table-sm-cell-padding;
78
79
      }
    }
80
  }
81
82
83
}


84
// Bordered version
85
86
//
// Add borders all around the table and between all the columns.
87

88
.table-bordered {
89
  border: 1px solid @table-border-color;
90
  > thead,
91
92
  > tbody,
  > tfoot {
93
94
95
    > tr {
      > th,
      > td {
96
        border: 1px solid @table-border-color;
97
      }
liuyl's avatar
liuyl committed
98
    }
99
  }
100
101
102
103
  > thead > tr {
    > th,
    > td {
      border-bottom-width: 2px;
104
105
    }
  }
Jacob Thornton's avatar
Jacob Thornton committed
106
107
}

108

109
// Zebra-striping
110
//
111
// Default zebra-stripe styles (alternating gray and transparent backgrounds)
112

113
114
.table-striped {
  > tbody > tr:nth-child(odd) {
115
    background-color: @table-bg-accent;
116
117
118
119
  }
}


120
// Hover effect
121
//
122
// Placed here since it has to come after the potential zebra striping
123

124
125
.table-hover {
  > tbody > tr:hover {
126
    background-color: @table-bg-hover;
127
128
129
  }
}

130

131
// Table cell sizing
132
//
133
// Reset default table behavior
134

boomsb's avatar
boomsb committed
135
table col[class*="col-"] {
136
  position: static; // Prevent border hiding in Firefox and IE9/10 (see https://github.com/twbs/bootstrap/issues/11623)
137
138
139
  float: none;
  display: table-column;
}
140
table {
141
142
  td,
  th {
boomsb's avatar
boomsb committed
143
    &[class*="col-"] {
144
      position: static; // Prevent border hiding in Firefox and IE9/10 (see https://github.com/twbs/bootstrap/issues/11623)
145
146
147
148
      float: none;
      display: table-cell;
    }
  }
149
150
}

151

152
// Table backgrounds
153
//
154
155
// Exact selectors below required to override `.table-striped` and prevent
// inheritance to nested tables.
156

157
// Generate the contextual variants
Zlatan Vasović's avatar
Zlatan Vasović committed
158
159
.table-row-variant(active; @table-bg-active);
.table-row-variant(success; @state-success-bg);
160
.table-row-variant(info; @state-info-bg);
Zlatan Vasović's avatar
Zlatan Vasović committed
161
.table-row-variant(warning; @state-warning-bg);
162
.table-row-variant(danger; @state-danger-bg);
163
164
165
166


// Responsive tables
//
167
// Wrap your tables in `.table-responsive` and we'll make them mobile friendly
168
169
170
// by enabling horizontal scrolling. Only applies <768px. Everything above that
// will display normally.

171
.table-responsive {
172
  overflow-x: auto;
173
  min-height: 0.01%; // Workaround for IE9 bug (see https://github.com/twbs/bootstrap/issues/14837)
174

175
  @media screen and (max-width: @screen-xs-max) {
176
    width: 100%;
177
    margin-bottom: (@line-height-computed * 0.75);
178
    overflow-y: hidden;
179
    -ms-overflow-style: -ms-autohiding-scrollbar;
180
181
    border: 1px solid @table-border-color;

182
    // Tighten up spacing
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
    > .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;
          }
        }
217
218
219
220
221
222
223
      }

      // 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 {
224
225
226
227
228
229
230
        > tr:last-child {
          > th,
          > td {
            border-bottom: 0;
          }
        }
      }
231

232
233
234
    }
  }
}
Mark Otto's avatar
Mark Otto committed
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249


.table > .thead-inverse {
  > tr > th {
    color: #fff;
    background-color: @gray-dark;
  }
}
.table > .thead-default {
  > tr > th {
    color: @gray;
    background-color: @gray-lighter;
  }
}

Mark Otto's avatar
Mark Otto committed
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
.table-inverse {
  color: @gray-lighter;
  background-color: @gray-dark;

  &.table-bordered {
    border: 0;
  }

  > thead,
  > tbody {
    > tr {
      > th,
      > td {
        border-color: @gray;
      }
    }
  }
}
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315


.table-reflow {

  thead {
    float: left;
  }

  tbody {
    display: block;
    white-space: nowrap;
  }

  > thead,
  > tbody,
  > tfoot {
    > tr {
      > th,
      > td {
        border-top: 1px solid @table-border-color;
        border-left: 1px solid @table-border-color;

        &:last-child {
          border-right: 1px solid @table-border-color;
        }
      }
    }

    &:last-child {
      > tr:last-child {
        > th,
        > td {
          border-bottom: 1px solid @table-border-color;
        }
      }
    }
  }

  tr {
    float: left;

    th,
    td {
      display: block !important;
      border: 1px solid @table-border-color;
    }
  }
}