_tables.scss 3.46 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
// Border versions
46
//
47
// Add or remove 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
67
68
69
70
71
72
.table-borderless {
  th,
  td,
  thead th,
  tbody + tbody {
    border: 0;
  }
}
73

74
// Zebra-striping
75
//
76
// Default zebra-stripe styles (alternating gray and transparent backgrounds)
77

78
.table-striped {
79
  tbody tr:nth-of-type(#{$table-striped-order}) {
80
    background-color: $table-accent-bg;
81
82
83
84
  }
}


85
// Hover effect
86
//
87
// Placed here since it has to come after the potential zebra striping
88

89
.table-hover {
90
91
  tbody tr {
    @include hover {
92
      background-color: $table-hover-bg;
93
    }
94
95
96
  }
}

97

98
// Table backgrounds
99
//
100
101
// Exact selectors below required to override `.table-striped` and prevent
// inheritance to nested tables.
102

103
104
105
@each $color, $value in $theme-colors {
  @include table-row-variant($color, theme-color-level($color, -9));
}
106

107
108
@include table-row-variant(active, $table-active-bg);

109

110
// Dark styles
111
//
112
// Same table markup, but inverted color scheme: dark background and light text.
Mark Otto's avatar
Mark Otto committed
113

114
// stylelint-disable-next-line no-duplicate-selectors
115
116
117
118
119
120
121
.table {
  .thead-dark {
    th {
      color: $table-dark-color;
      background-color: $table-dark-bg;
      border-color: $table-dark-border-color;
    }
Mark Otto's avatar
Mark Otto committed
122
  }
123

124
125
126
127
128
129
  .thead-light {
    th {
      color: $table-head-color;
      background-color: $table-head-bg;
      border-color: $table-border-color;
    }
Mark Otto's avatar
Mark Otto committed
130
131
132
  }
}

133
.table-dark {
134
135
  color: $table-dark-color;
  background-color: $table-dark-bg;
Mark Otto's avatar
Mark Otto committed
136

137
  th,
Mark Otto's avatar
Mark Otto committed
138
139
  td,
  thead th {
140
    border-color: $table-dark-border-color;
Mark Otto's avatar
Mark Otto committed
141
  }
142
143
144
145

  &.table-bordered {
    border: 0;
  }
146
147
148

  &.table-striped {
    tbody tr:nth-of-type(odd) {
149
      background-color: $table-dark-accent-bg;
150
151
152
153
154
155
    }
  }

  &.table-hover {
    tbody tr {
      @include hover {
156
        background-color: $table-dark-hover-bg;
157
158
159
      }
    }
  }
160
161
162
163
164
}


// Responsive tables
//
165
166
// Generate series of `.table-responsive-*` classes for configuring the screen
// size of where your table will overflow.
167
168

.table-responsive {
169
170
171
172
173
174
175
176
177
  @each $breakpoint in map-keys($grid-breakpoints) {
    $next: breakpoint-next($breakpoint, $grid-breakpoints);
    $infix: breakpoint-infix($next, $grid-breakpoints);

    &#{$infix} {
      @include media-breakpoint-down($breakpoint) {
        display: block;
        width: 100%;
        overflow-x: auto;
178
        -webkit-overflow-scrolling: touch;
179
180
181
        -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;`
182
        > .table-bordered {
183
184
185
          border: 0;
        }
      }
186
    }
187
  }
Mark Otto's avatar
Mark Otto committed
188
}