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

12
13
14
  th,
  td {
    padding: $table-cell-padding;
Mark Otto's avatar
Mark Otto committed
15
16
17
    border-bottom: $table-border-width solid $table-border-color;
  }

18
19
20
21
  tbody {
    vertical-align: inherit;
  }

22
  thead th {
23
    vertical-align: bottom;
Mark Otto's avatar
Mark Otto committed
24
    border-bottom-color: $table-head-border-color;
25
  }
26
27

  tbody + tbody {
28
    border-top: (2 * $table-border-width) solid $table-border-color;
29
  }
30
31
}

32

33
34
35
36
37
38
39
//
// Change placement of captions with a class
//

.caption-top { caption-side: top; }


40
//
41
// Condensed table w/ half padding
42
//
43

44
.table-sm {
45
46
  th,
  td {
47
    padding: $table-cell-padding-sm;
48
  }
49
50
51
}


52
// Border versions
53
//
54
// Add or remove borders all around the table and between all the columns.
55

56
.table-bordered {
57
  border: $table-border-width solid $table-border-color;
58
59
60

  th,
  td {
61
    border: $table-border-width solid $table-border-color;
62
  }
63
64
65
66

  thead {
    th,
    td {
67
      border-bottom-width: 2 * $table-border-width;
68
69
    }
  }
Jacob Thornton's avatar
Jacob Thornton committed
70
71
}

72
73
74
75
76
77
78
79
.table-borderless {
  th,
  td,
  thead th,
  tbody + tbody {
    border: 0;
  }
}
80

81
// Zebra-striping
82
//
83
// Default zebra-stripe styles (alternating gray and transparent backgrounds)
84

85
.table-striped {
86
  tbody tr:nth-of-type(#{$table-striped-order}) {
87
    background-color: $table-accent-bg;
88
89
90
91
  }
}


92
// Hover effect
93
//
94
// Placed here since it has to come after the potential zebra striping
95

96
.table-hover {
97
  tbody tr {
Mark Otto's avatar
Mark Otto committed
98
    &:hover {
Mark Otto's avatar
Mark Otto committed
99
      color: $table-hover-color;
100
      background-color: $table-hover-bg;
101
    }
102
103
104
  }
}

105

106
// Table backgrounds
107
//
108
109
// Exact selectors below required to override `.table-striped` and prevent
// inheritance to nested tables.
110

111
@each $color, $value in $theme-colors {
112
  @include table-row-variant($color, color-level($value, $table-bg-level), color-level($value, $table-border-level));
113
}
114

115
116
@include table-row-variant(active, $table-active-bg);

117

118
// Dark styles
119
//
120
// Same table markup, but inverted color scheme: dark background and light text.
Mark Otto's avatar
Mark Otto committed
121

122
// stylelint-disable-next-line no-duplicate-selectors
123
124
125
126
127
128
129
.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
130
  }
131

132
133
134
135
136
137
  .thead-light {
    th {
      color: $table-head-color;
      background-color: $table-head-bg;
      border-color: $table-border-color;
    }
Mark Otto's avatar
Mark Otto committed
138
139
140
  }
}

141
.table-dark {
142
143
  color: $table-dark-color;
  background-color: $table-dark-bg;
Mark Otto's avatar
Mark Otto committed
144

145
  th,
Mark Otto's avatar
Mark Otto committed
146
147
  td,
  thead th {
148
    border-color: $table-dark-border-color;
Mark Otto's avatar
Mark Otto committed
149
  }
150
151
152
153

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

  &.table-striped {
zhangbao's avatar
zhangbao committed
156
    tbody tr:nth-of-type(#{$table-striped-order}) {
157
      background-color: $table-dark-accent-bg;
158
159
160
161
162
    }
  }

  &.table-hover {
    tbody tr {
Mark Otto's avatar
Mark Otto committed
163
      &:hover {
Mark Otto's avatar
Mark Otto committed
164
        color: $table-dark-hover-color;
165
        background-color: $table-dark-hover-bg;
166
167
168
      }
    }
  }
169
170
171
172
173
}


// Responsive tables
//
174
175
// Generate series of `.table-responsive-*` classes for configuring the screen
// size of where your table will overflow.
176

177
178
179
180
181
182
183
184
@each $breakpoint in map-keys($grid-breakpoints) {
  $next: breakpoint-next($breakpoint, $grid-breakpoints);
  $infix: breakpoint-infix($next, $grid-breakpoints);

  @include media-breakpoint-down($breakpoint) {
    .table-responsive#{$infix} {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
185
    }
186
  }
Mark Otto's avatar
Mark Otto committed
187
}