_tables.scss 3.77 KB
Newer Older
1
//
2
3
// Reset tabular elements
//
Jacob Thornton's avatar
Jacob Thornton committed
4

5
table {
Mark Otto's avatar
Mark Otto committed
6
  background-color: $table-bg;
7
}
8

9
caption {
Mark Otto's avatar
Mark Otto committed
10
11
12
  padding-top: $table-cell-padding;
  padding-bottom: $table-cell-padding;
  color: $text-muted;
13
14
  text-align: left;
}
15

16
17
18
th {
  text-align: left;
}
19
20


21
22
23
//
// Basic tables
//
Jacob Thornton's avatar
Jacob Thornton committed
24

25
.table {
Jacob Thornton's avatar
Jacob Thornton committed
26
  width: 100%;
27
  max-width: 100%;
Mark Otto's avatar
Mark Otto committed
28
29
  margin-bottom: $spacer;

30
31
32
33
34
35
  th,
  td {
    padding: $table-cell-padding;
    line-height: $line-height-base;
    vertical-align: top;
    border-top: 1px solid $table-border-color;
36
  }
37
38

  thead th {
39
    vertical-align: bottom;
Mark Otto's avatar
Mark Otto committed
40
    border-bottom: 2px solid $table-border-color;
41
  }
42
43

  tbody + tbody {
Mark Otto's avatar
Mark Otto committed
44
    border-top: 2px solid $table-border-color;
45
  }
Mark Otto's avatar
Mark Otto committed
46

47
48
49
  .table {
    background-color: $body-bg;
  }
50
51
}

52

53
//
54
// Condensed table w/ half padding
55
//
56

57
.table-sm {
58
59
60
  th,
  td {
    padding: $table-sm-cell-padding;
61
  }
62
63
64
}


65
// Bordered version
66
67
//
// Add borders all around the table and between all the columns.
68

69
.table-bordered {
Mark Otto's avatar
Mark Otto committed
70
  border: 1px solid $table-border-color;
71
72
73
74

  th,
  td {
    border: 1px solid $table-border-color;
75
  }
76
77
78
79

  thead {
    th,
    td {
80
      border-bottom-width: 2px;
81
82
    }
  }
Jacob Thornton's avatar
Jacob Thornton committed
83
84
}

85

86
// Zebra-striping
87
//
88
// Default zebra-stripe styles (alternating gray and transparent backgrounds)
89

90
.table-striped {
Mark Otto's avatar
Mark Otto committed
91
  tbody tr:nth-of-type(odd) {
Mark Otto's avatar
Mark Otto committed
92
    background-color: $table-bg-accent;
93
94
95
96
  }
}


97
// Hover effect
98
//
99
// Placed here since it has to come after the potential zebra striping
100

101
.table-hover {
102
  tbody tr:hover {
Mark Otto's avatar
Mark Otto committed
103
    background-color: $table-bg-hover;
104
105
106
  }
}

107

108
// Table cell sizing
109
//
110
// Reset default table behavior
111

boomsb's avatar
boomsb committed
112
table col[class*="col-"] {
Mark Otto's avatar
Mark Otto committed
113
  position: static; // Prevent border hiding in Firefox and IE9-11 (see https://github.com/twbs/bootstrap/issues/11623)
114
  display: table-column;
115
  float: none;
116
}
117

118
table {
119
120
  td,
  th {
boomsb's avatar
boomsb committed
121
    &[class*="col-"] {
Mark Otto's avatar
Mark Otto committed
122
      position: static; // Prevent border hiding in Firefox and IE9-11 (see https://github.com/twbs/bootstrap/issues/11623)
123
      display: table-cell;
124
      float: none;
125
126
    }
  }
127
128
}

129

130
// Table backgrounds
131
//
132
133
// Exact selectors below required to override `.table-striped` and prevent
// inheritance to nested tables.
134

135
// Generate the contextual variants
Mark Otto's avatar
Mark Otto committed
136
137
138
139
140
@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);
141
142
143
144


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

149
.table-responsive {
150
151
  display: block;
  width: 100%;
152
  overflow-x: auto;
153

154
155
156
157
158
  // Todo: find out if we need this still.
  //
  // border: 1px solid $table-border-color;
  // -ms-overflow-style: -ms-autohiding-scrollbar;
  // min-height: 0.01%; // Workaround for IE9 bug (see https://github.com/twbs/bootstrap/issues/14837)
159
}
Mark Otto's avatar
Mark Otto committed
160
161


162
163
.thead-inverse {
  th {
Mark Otto's avatar
Mark Otto committed
164
    color: #fff;
Mark Otto's avatar
Mark Otto committed
165
    background-color: $gray-dark;
Mark Otto's avatar
Mark Otto committed
166
167
  }
}
168
169
.thead-default {
  th {
Mark Otto's avatar
Mark Otto committed
170
171
    color: $gray;
    background-color: $gray-lighter;
Mark Otto's avatar
Mark Otto committed
172
173
174
  }
}

Mark Otto's avatar
Mark Otto committed
175
.table-inverse {
Mark Otto's avatar
Mark Otto committed
176
177
  color: $gray-lighter;
  background-color: $gray-dark;
Mark Otto's avatar
Mark Otto committed
178
179
180
181
182

  &.table-bordered {
    border: 0;
  }

183
  th,
Mark Otto's avatar
Mark Otto committed
184
185
  td,
  thead th {
186
    border-color: $gray;
Mark Otto's avatar
Mark Otto committed
187
188
  }
}
189
190
191
192
193
194
195
196
197
198
199
200


.table-reflow {
  thead {
    float: left;
  }

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

201
202
203
204
205
206
207
  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;
208
    }
209
  }
210

211
212
213
  thead,
  tbody,
  tfoot {
214
    &:last-child {
215
216
217
      tr:last-child {
        th,
        td {
Mark Otto's avatar
Mark Otto committed
218
          border-bottom: 1px solid $table-border-color;
219
220
221
222
223
224
225
226
227
228
229
        }
      }
    }
  }

  tr {
    float: left;

    th,
    td {
      display: block !important;
Mark Otto's avatar
Mark Otto committed
230
      border: 1px solid $table-border-color;
231
232
233
    }
  }
}