_tables.scss 2.98 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
  margin-bottom: $spacer;
9
  background-color: $table-bg; // Reset for nesting within parents with `background-color`.
Mark Otto's avatar
Mark Otto committed
10

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

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

  tbody + tbody {
24
    border-top: (2 * $table-border-width) 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
  th,
  td {
40
    padding: $table-cell-padding-sm;
41
  }
42
43
44
}


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

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

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

  thead {
    th,
    td {
60
      border-bottom-width: (2 * $table-border-width);
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) {
72
    background-color: $table-accent-bg;
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
  tbody tr {
    @include hover {
84
      background-color: $table-hover-bg;
85
    }
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
96
97
@each $color, $value in $theme-colors {
  @include table-row-variant($color, theme-color-level($color, -9));
}
98

99
100
@include table-row-variant(active, $table-active-bg);

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 {
108
109
    color: $table-inverse-color;
    background-color: $table-inverse-bg;
Mark Otto's avatar
Mark Otto committed
110
111
  }
}
112

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

Mark Otto's avatar
Mark Otto committed
120
.table-inverse {
121
122
  color: $table-inverse-color;
  background-color: $table-inverse-bg;
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: $table-inverse-border-color;
Mark Otto's avatar
Mark Otto committed
128
  }
129
130
131
132

  &.table-bordered {
    border: 0;
  }
133
134
135

  &.table-striped {
    tbody tr:nth-of-type(odd) {
136
      background-color: $table-inverse-accent-bg;
137
138
139
140
141
142
    }
  }

  &.table-hover {
    tbody tr {
      @include hover {
143
        background-color: $table-inverse-hover-bg;
144
145
146
      }
    }
  }
147
148
149
150
151
}


// Responsive tables
//
Mark Otto's avatar
Mark Otto committed
152
153
// Add `.table-responsive` to `.table`s and we'll make them mobile friendly by
// enabling horizontal scrolling. Only applies <768px. Everything above that
154
155
156
// will display normally.

.table-responsive {
157
158
159
160
161
162
163
164
165
166
  @include media-breakpoint-down(md) {
    display: block;
    width: 100%;
    overflow-x: auto;
    -ms-overflow-style: -ms-autohiding-scrollbar; // See https://github.com/twbs/bootstrap/pull/10057

    // Prevent double border on horizontal scroll due to use of `display: block;`
    &.table-bordered {
      border: 0;
    }
167
  }
Mark Otto's avatar
Mark Otto committed
168
}