tables.less 2.84 KB
Newer Older
1
//
2
3
// Tables
// --------------------------------------------------
Jacob Thornton's avatar
Jacob Thornton committed
4

5

6
7
table {
  max-width: 100%;
8
  background-color: @table-bg;
9
}
10
11
12
th {
  text-align: left;
}
13
14


15
// Baseline styles
16
// ---------------
Jacob Thornton's avatar
Jacob Thornton committed
17

18
.table {
Jacob Thornton's avatar
Jacob Thornton committed
19
  width: 100%;
20
  margin-bottom: @line-height-computed;
21
  // Cells
22
  thead,
23
24
  tbody,
  tfoot {
25
26
27
    > tr {
      > th,
      > td {
28
        padding: @table-cell-padding;
29
30
31
32
33
        line-height: @line-height-base;
        vertical-align: top;
        border-top: 1px solid @table-border-color;
      }
    }
34
  }
35
  // Bottom align for column headings
36
  thead > tr > th {
37
    vertical-align: bottom;
38
    border-bottom: 2px solid @table-border-color;
39
40
  }
  // Remove top border from thead by default
41
42
43
44
45
46
47
48
  caption + thead,
  colgroup + thead,
  thead:first-child {
    tr:first-child {
      th, td {
        border-top: 0;
      }
    }
49
50
51
  }
  // Account for multiple tbody instances
  tbody + tbody {
52
    border-top: 2px solid @table-border-color;
53
  }
Mark Otto's avatar
Mark Otto committed
54
55
56

  // Nesting
  .table {
57
    background-color: @body-bg;
Mark Otto's avatar
Mark Otto committed
58
  }
59
60
}

61
62


63
// Condensed table w/ half padding
64
// -------------------------------
65

66
.table-condensed {
67
  thead,
68
69
  tbody,
  tfoot {
70
71
72
    > tr {
      > th,
      > td {
73
        padding: @table-condensed-cell-padding;
74
75
      }
    }
76
  }
77
78
79
}


80

81
// Bordered version
82
83
// ----------------

84
.table-bordered {
85
  border: 1px solid @table-border-color;
86
  > thead,
87
88
  > tbody,
  > tfoot {
89
90
91
    > tr {
      > th,
      > td {
92
        border: 1px solid @table-border-color;
93
      }
liuyl's avatar
liuyl committed
94
    }
95
  }
96
97
98
99
100
101
102
103
  > thead {
    > tr {
      > th,
      > td {
        border-bottom-width: 2px;
      }
    }
  }
Jacob Thornton's avatar
Jacob Thornton committed
104
105
}

106

107

108
// Zebra-striping
109
110
111
// --------------

// Default zebra-stripe styles (alternating gray and transparent backgrounds)
112
.table-striped {
113
  > tbody {
114
115
116
117
118
    > tr:nth-child(odd) {
      > td,
      > th {
        background-color: @table-bg-accent;
      }
119
120
121
122
123
    }
  }
}


124

125
// Hover effect
126
// ------------
127

128
// Placed here since it has to come after the potential zebra striping
129
.table-hover {
130
  > tbody {
131
132
133
134
135
    > tr:hover {
      > td,
      > th {
        background-color: @table-bg-hover;
      }
136
    }
137
138
139
  }
}

140

141

142
// Table cell sizing
143
// -----------------
144

145
// Reset default table behavior
146
table col[class^="col-"] {
147
148
149
  float: none;
  display: table-column;
}
150
table {
151
152
  td,
  th {
153
154
155
156
157
    &[class^="col-"] {
      float: none;
      display: table-cell;
    }
  }
158
159
}

160
161


162
// Table backgrounds
163
// -----------------
164
165
// Exact selectors below required to override `.table-striped` and prevent
// inheritance to nested tables.
166

167
168
169
.table > thead > tr,
.table > tbody > tr,
.table > tfoot > tr {
170
171
  > td.active,
  > th.active,
172
173
  &.active > td,
  &.active > th  {
174
    background-color: @table-bg-active;
175
  }
176
}
177

ggam's avatar
ggam committed
178
179
180
181
182
183
184
// Contextual variants
// -------------------
.table-row-variant(success; @state-success-bg; @state-success-border);

.table-row-variant(danger; @state-danger-bg; @state-danger-border);

.table-row-variant(warning; @state-warning-bg; @state-warning-border);