_tables.scss 3.12 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
// Generate the contextual variants
96
@include table-row-variant(active, $table-active-bg);
Mark Otto's avatar
Mark Otto committed
97
98
99
100
@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
// Inverse styles
104
//
105
// Same table markup, but inverted color scheme: dark background and light text.
Mark Otto's avatar
Mark Otto committed
106

107
108
.thead-inverse {
  th {
109
110
    color: $table-inverse-color;
    background-color: $table-inverse-bg;
Mark Otto's avatar
Mark Otto committed
111
112
  }
}
113

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

Mark Otto's avatar
Mark Otto committed
121
.table-inverse {
122
123
  color: $table-inverse-color;
  background-color: $table-inverse-bg;
Mark Otto's avatar
Mark Otto committed
124

125
  th,
Mark Otto's avatar
Mark Otto committed
126
127
  td,
  thead th {
128
    border-color: $table-inverse-border-color;
Mark Otto's avatar
Mark Otto committed
129
  }
130
131
132
133

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

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

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


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

.table-responsive {
158
159
160
161
162
163
164
165
166
167
  @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;
    }
168
  }
Mark Otto's avatar
Mark Otto committed
169
}