_tables.scss 3.5 KB
Newer Older
1
//
2
// Basic Bootstrap table
3
//
Jacob Thornton's avatar
Jacob Thornton committed
4

5
.table {
Jacob Thornton's avatar
Jacob Thornton committed
6
  width: 100%;
7
  max-width: 100%;
Mark Otto's avatar
Mark Otto committed
8
9
  margin-bottom: $spacer;

10
11
12
13
  th,
  td {
    padding: $table-cell-padding;
    vertical-align: top;
14
    border-top: $table-border-width solid $table-border-color;
15
  }
16
17

  thead th {
18
    vertical-align: bottom;
19
    border-bottom: (2 * $table-border-width) solid $table-border-color;
20
  }
21
22

  tbody + tbody {
23
    border-top: (2 * $table-border-width) solid $table-border-color;
24
  }
Mark Otto's avatar
Mark Otto committed
25

26
27
28
  .table {
    background-color: $body-bg;
  }
29
30
}

31

32
//
33
// Condensed table w/ half padding
34
//
35

36
.table-sm {
37
38
39
  th,
  td {
    padding: $table-sm-cell-padding;
40
  }
41
42
43
}


44
// Bordered version
45
46
//
// Add borders all around the table and between all the columns.
47

48
.table-bordered {
49
  border: $table-border-width solid $table-border-color;
50
51
52

  th,
  td {
53
    border: $table-border-width solid $table-border-color;
54
  }
55
56
57
58

  thead {
    th,
    td {
59
      border-bottom-width: (2 * $table-border-width);
60
61
    }
  }
Jacob Thornton's avatar
Jacob Thornton committed
62
63
}

64

65
// Zebra-striping
66
//
67
// Default zebra-stripe styles (alternating gray and transparent backgrounds)
68

69
.table-striped {
Mark Otto's avatar
Mark Otto committed
70
  tbody tr:nth-of-type(odd) {
Mark Otto's avatar
Mark Otto committed
71
    background-color: $table-bg-accent;
72
73
74
75
  }
}


76
// Hover effect
77
//
78
// Placed here since it has to come after the potential zebra striping
79

80
.table-hover {
81
82
83
84
  tbody tr {
    @include hover {
      background-color: $table-bg-hover;
    }
85
86
87
  }
}

88

89
// Table backgrounds
90
//
91
92
// Exact selectors below required to override `.table-striped` and prevent
// inheritance to nested tables.
93

94
// Generate the contextual variants
Mark Otto's avatar
Mark Otto committed
95
96
97
98
99
@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);
100
101


102
// Inverse styles
103
//
104
// Same table markup, but inverted color scheme—dark background and light text.
Mark Otto's avatar
Mark Otto committed
105

106
107
.thead-inverse {
  th {
Mark Otto's avatar
Mark Otto committed
108
    color: #fff;
Mark Otto's avatar
Mark Otto committed
109
    background-color: $gray-dark;
Mark Otto's avatar
Mark Otto committed
110
111
  }
}
112

113
114
.thead-default {
  th {
Mark Otto's avatar
Mark Otto committed
115
116
    color: $gray;
    background-color: $gray-lighter;
Mark Otto's avatar
Mark Otto committed
117
118
119
  }
}

Mark Otto's avatar
Mark Otto committed
120
.table-inverse {
Mark Otto's avatar
Mark Otto committed
121
122
  color: $gray-lighter;
  background-color: $gray-dark;
Mark Otto's avatar
Mark Otto committed
123

124
  th,
Mark Otto's avatar
Mark Otto committed
125
126
  td,
  thead th {
127
    border-color: $gray;
Mark Otto's avatar
Mark Otto committed
128
  }
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152

  &.table-bordered {
    border: 0;
  }
}



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

.table-responsive {
  display: block;
  width: 100%;
  min-height: .01%; // Workaround for IE9 bug (see https://github.com/twbs/bootstrap/issues/14837)
  overflow-x: auto;

  // TODO: find out if we need this still.
  //
  // border: $table-border-width solid $table-border-color;
  // -ms-overflow-style: -ms-autohiding-scrollbar; // See https://github.com/twbs/bootstrap/pull/10057
Mark Otto's avatar
Mark Otto committed
153
}
154
155
156
157
158
159
160
161
162
163
164
165


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

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

166
167
  th,
  td {
168
169
    border-top: $table-border-width solid $table-border-color;
    border-left: $table-border-width solid $table-border-color;
170
171

    &:last-child {
172
      border-right: $table-border-width solid $table-border-color;
173
    }
174
  }
175

176
177
178
  thead,
  tbody,
  tfoot {
179
    &:last-child {
Mark Otto's avatar
Mark Otto committed
180
181
182
      tr:last-child th,
      tr:last-child td {
        border-bottom: $table-border-width solid $table-border-color;
183
184
185
186
      }
    }
  }

Mark Otto's avatar
Mark Otto committed
187
  // scss-lint:disable ImportantRule
188
189
190
191
192
193
  tr {
    float: left;

    th,
    td {
      display: block !important;
194
      border: $table-border-width solid $table-border-color;
195
196
    }
  }
Mark Otto's avatar
Mark Otto committed
197
  // scss-lint:enable ImportantRule
198
}