tables.less 3.32 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
39
  }
  // Remove top border from thead by default
40
41
42
43
44
45
46
47
  caption + thead,
  colgroup + thead,
  thead:first-child {
    tr:first-child {
      th, td {
        border-top: 0;
      }
    }
48
49
50
  }
  // Account for multiple tbody instances
  tbody + tbody {
51
    border-top: 2px solid @table-border-color;
52
  }
Mark Otto's avatar
Mark Otto committed
53
54
55

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

60
61


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

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


79

80
// Bordered version
81
82
// ----------------

83
.table-bordered {
84
  border: 1px solid @table-border-color;
85
  > thead,
86
87
  > tbody,
  > tfoot {
88
89
90
    > tr {
      > th,
      > td {
91
        border: 1px solid @table-border-color;
92
      }
liuyl's avatar
liuyl committed
93
    }
94
  }
Jacob Thornton's avatar
Jacob Thornton committed
95
96
}

97

98

99
// Zebra-striping
100
101
102
// --------------

// Default zebra-stripe styles (alternating gray and transparent backgrounds)
103
.table-striped {
104
  > tbody {
105
106
107
108
109
    > tr:nth-child(odd) {
      > td,
      > th {
        background-color: @table-bg-accent;
      }
110
111
112
113
114
    }
  }
}


115

116
// Hover effect
117
// ------------
118

119
// Placed here since it has to come after the potential zebra striping
120
.table-hover {
121
  > tbody {
122
123
124
125
126
    > tr:hover {
      > td,
      > th {
        background-color: @table-bg-hover;
      }
127
    }
128
129
130
  }
}

131

132

133
// Table cell sizing
134
// -----------------
135

136
// Reset default table behavior
137
table col[class^="col-"] {
138
139
140
  float: none;
  display: table-column;
}
141
table {
142
143
  td,
  th {
144
145
146
147
148
    &[class^="col-"] {
      float: none;
      display: table-cell;
    }
  }
149
150
}

151
152


153
// Table backgrounds
154
155
156
// -----------------
// Exact selectors below required to override .table-striped

157
.table > tbody > tr {
158
159
160
161
162
  > td.active,
  > th.active,
  &.active > td {
    background-color: @table-bg-hover;
  }
163
164
  > td.success,
  > th.success,
165
  &.success > td {
166
    background-color: @state-success-bg;
167
    border-color: @state-success-border;
168
  }
169
170
171
  > td.danger,
  > th.danger,
  &.danger > td {
172
    background-color: @state-danger-bg;
173
    border-color: @state-danger-border;
174
  }
175
176
  > td.warning,
  > th.warning,
177
  &.warning > td {
178
    background-color: @state-warning-bg;
179
    border-color: @state-warning-border;
180
  }
181
}
182
183

// Hover states for .table-hover
184
.table-hover > tbody > tr {
185
186
  > td.success:hover,
  > th.success:hover,
187
  &.success:hover > td {
188
    background-color: darken(@state-success-bg, 5%);
189
    border-color: darken(@state-success-border, 5%);
190
  }
191
192
193
  > td.danger:hover,
  > th.danger:hover,
  &.danger:hover > td {
194
    background-color: darken(@state-danger-bg, 5%);
195
    border-color: darken(@state-danger-border, 5%);
196
  }
197
198
  > td.warning:hover,
  > th.warning:hover,
199
  &.warning:hover > td {
200
    background-color: darken(@state-warning-bg, 5%);
201
    border-color: darken(@state-warning-border, 5%);
202
203
  }
}