_tables.scss 3.16 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
  th,
  td {
    padding: $table-cell-padding;
13
    line-height: $line-height;
14
15
    vertical-align: top;
    border-top: 1px solid $table-border-color;
16
  }
17
18

  thead th {
19
    vertical-align: bottom;
Mark Otto's avatar
Mark Otto committed
20
    border-bottom: 2px solid $table-border-color;
21
  }
22
23

  tbody + tbody {
Mark Otto's avatar
Mark Otto committed
24
    border-top: 2px solid $table-border-color;
25
  }
Mark Otto's avatar
Mark Otto committed
26

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

32

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

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


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

49
.table-bordered {
Mark Otto's avatar
Mark Otto committed
50
  border: 1px solid $table-border-color;
51
52
53
54

  th,
  td {
    border: 1px solid $table-border-color;
55
  }
56
57
58
59

  thead {
    th,
    td {
60
      border-bottom-width: 2px;
61
62
    }
  }
Jacob Thornton's avatar
Jacob Thornton committed
63
64
}

65

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

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


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

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

89

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

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


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

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

115
  // TODO: find out if we need this still.
116
117
  //
  // border: 1px solid $table-border-color;
118
  // -ms-overflow-style: -ms-autohiding-scrollbar; // See https://github.com/twbs/bootstrap/pull/10057
119
}
Mark Otto's avatar
Mark Otto committed
120
121


122
123
.thead-inverse {
  th {
Mark Otto's avatar
Mark Otto committed
124
    color: #fff;
Mark Otto's avatar
Mark Otto committed
125
    background-color: $gray-dark;
Mark Otto's avatar
Mark Otto committed
126
127
  }
}
128
129
.thead-default {
  th {
Mark Otto's avatar
Mark Otto committed
130
131
    color: $gray;
    background-color: $gray-lighter;
Mark Otto's avatar
Mark Otto committed
132
133
134
  }
}

Mark Otto's avatar
Mark Otto committed
135
.table-inverse {
Mark Otto's avatar
Mark Otto committed
136
137
  color: $gray-lighter;
  background-color: $gray-dark;
Mark Otto's avatar
Mark Otto committed
138
139
140
141
142

  &.table-bordered {
    border: 0;
  }

143
  th,
Mark Otto's avatar
Mark Otto committed
144
145
  td,
  thead th {
146
    border-color: $gray;
Mark Otto's avatar
Mark Otto committed
147
148
  }
}
149
150
151
152
153
154
155
156
157
158
159
160


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

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

161
162
163
164
165
166
167
  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;
168
    }
169
  }
170

171
172
173
  thead,
  tbody,
  tfoot {
174
    &:last-child {
175
176
177
      tr:last-child {
        th,
        td {
Mark Otto's avatar
Mark Otto committed
178
          border-bottom: 1px solid $table-border-color;
179
180
181
182
183
184
185
186
187
188
189
        }
      }
    }
  }

  tr {
    float: left;

    th,
    td {
      display: block !important;
Mark Otto's avatar
Mark Otto committed
190
      border: 1px solid $table-border-color;
191
192
193
    }
  }
}