_tables.scss 3.29 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
// Dark 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
108
109
110
111
112
.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
113
  }
114

115
116
117
118
119
120
  .thead-light {
    th {
      color: $table-head-color;
      background-color: $table-head-bg;
      border-color: $table-border-color;
    }
Mark Otto's avatar
Mark Otto committed
121
122
123
  }
}

124
.table-dark {
125
126
  color: $table-dark-color;
  background-color: $table-dark-bg;
Mark Otto's avatar
Mark Otto committed
127

128
  th,
Mark Otto's avatar
Mark Otto committed
129
130
  td,
  thead th {
131
    border-color: $table-dark-border-color;
Mark Otto's avatar
Mark Otto committed
132
  }
133
134
135
136

  &.table-bordered {
    border: 0;
  }
137
138
139

  &.table-striped {
    tbody tr:nth-of-type(odd) {
140
      background-color: $table-dark-accent-bg;
141
142
143
144
145
146
    }
  }

  &.table-hover {
    tbody tr {
      @include hover {
147
        background-color: $table-dark-hover-bg;
148
149
150
      }
    }
  }
151
152
153
154
155
}


// Responsive tables
//
156
157
// Generate series of `.table-responsive-*` classes for configuring the screen
// size of where your table will overflow.
158
159

.table-responsive {
160
161
162
163
164
165
166
167
168
  @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;
169
        -webkit-overflow-scrolling: touch;
170
171
172
173
174
175
176
        -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;
        }
      }
177
    }
178
  }
Mark Otto's avatar
Mark Otto committed
179
}