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

5
table {
Mark Otto's avatar
Mark Otto committed
6
  background-color: $table-bg;
7
}
8
caption {
Mark Otto's avatar
Mark Otto committed
9
10
11
  padding-top: $table-cell-padding;
  padding-bottom: $table-cell-padding;
  color: $text-muted;
12
13
  text-align: left;
}
14
15
16
th {
  text-align: left;
}
17
18


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

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

  // Nesting
61
//  .table {
Mark Otto's avatar
Mark Otto committed
62
//    background-color: $body-bg;
63
//  }
64
65
}

66

67
// Condensed table w/ half padding
68

69
.table-sm {
70
71
72
  > thead,
  > tbody,
  > tfoot {
73
74
75
    > tr {
      > th,
      > td {
Mark Otto's avatar
Mark Otto committed
76
        padding: $table-sm-cell-padding;
77
78
      }
    }
79
  }
80
81
82
}


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

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

107

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

112
113
.table-striped {
  > tbody > tr:nth-child(odd) {
Mark Otto's avatar
Mark Otto committed
114
    background-color: $table-bg-accent;
115
116
117
118
  }
}


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

123
124
.table-hover {
  > tbody > tr:hover {
Mark Otto's avatar
Mark Otto committed
125
    background-color: $table-bg-hover;
126
127
128
  }
}

129

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

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

150

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

156
// Generate the contextual variants
Mark Otto's avatar
Mark Otto committed
157
158
159
160
161
@include table-row-variant(active, $table-bg-active);
@include table-row-variant(success, $state-success-bg);
@include table-row-variant(info, $state-info-bg);
@include table-row-variant(warning, $state-warning-bg);
@include table-row-variant(danger, $state-danger-bg);
162
163
164
165


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

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

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

181
    // Tighten up spacing
182
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
    > .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;
          }
        }
216
217
218
219
220
221
222
      }

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

231
232
233
    }
  }
}
Mark Otto's avatar
Mark Otto committed
234
235
236
237
238


.table > .thead-inverse {
  > tr > th {
    color: #fff;
Mark Otto's avatar
Mark Otto committed
239
    background-color: $gray-dark;
Mark Otto's avatar
Mark Otto committed
240
241
242
243
  }
}
.table > .thead-default {
  > tr > th {
Mark Otto's avatar
Mark Otto committed
244
245
    color: $gray;
    background-color: $gray-lighter;
Mark Otto's avatar
Mark Otto committed
246
247
248
  }
}

Mark Otto's avatar
Mark Otto committed
249
.table-inverse {
Mark Otto's avatar
Mark Otto committed
250
251
  color: $gray-lighter;
  background-color: $gray-dark;
Mark Otto's avatar
Mark Otto committed
252
253
254
255
256
257
258
259
260
261

  &.table-bordered {
    border: 0;
  }

  > thead,
  > tbody {
    > tr {
      > th,
      > td {
Mark Otto's avatar
Mark Otto committed
262
        border-color: $gray;
Mark Otto's avatar
Mark Otto committed
263
264
265
266
      }
    }
  }
}
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285


.table-reflow {

  thead {
    float: left;
  }

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

  > thead,
  > tbody,
  > tfoot {
    > tr {
      > th,
      > td {
Mark Otto's avatar
Mark Otto committed
286
287
        border-top: 1px solid $table-border-color;
        border-left: 1px solid $table-border-color;
288
289

        &:last-child {
Mark Otto's avatar
Mark Otto committed
290
          border-right: 1px solid $table-border-color;
291
292
293
294
295
296
297
298
        }
      }
    }

    &:last-child {
      > tr:last-child {
        > th,
        > td {
Mark Otto's avatar
Mark Otto committed
299
          border-bottom: 1px solid $table-border-color;
300
301
302
303
304
305
306
307
308
309
310
        }
      }
    }
  }

  tr {
    float: left;

    th,
    td {
      display: block !important;
Mark Otto's avatar
Mark Otto committed
311
      border: 1px solid $table-border-color;
312
313
314
    }
  }
}