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

5

6
7
8
9
10
// BASE TABLES
// -----------------

table {
  max-width: 100%;
Jacob Thornton's avatar
Jacob Thornton committed
11
  background-color: @tableBackground;
12
13
14
15
  border-collapse: collapse;
  border-spacing: 0;
}

16
17
// BASELINE STYLES
// ---------------
Jacob Thornton's avatar
Jacob Thornton committed
18

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

  // Nesting
  .table {
    background-color: @bodyBackground;
  }
56
57
}

58
59


60
61
// CONDENSED TABLE W/ HALF PADDING
// -------------------------------
62

63
.table-condensed {
64
65
  th,
  td {
66
    padding: 4px 5px;
67
  }
68
69
70
71
72
73
}


// BORDERED VERSION
// ----------------

74
.table-bordered {
Mark Otto's avatar
Mark Otto committed
75
  border: 1px solid @tableBorder;
76
  border-collapse: separate; // Done so we can round those corners!
77
  *border-collapse: collapse; // IE7 can't round corners anyway
Jacob Thornton's avatar
Jacob Thornton committed
78
  border-left: 0;
79
  .border-radius(@baseBorderRadius);
80
81
  th,
  td {
Mark Otto's avatar
Mark Otto committed
82
    border-left: 1px solid @tableBorder;
83
  }
84
  // Prevent a double border
85
86
87
88
89
90
  caption + thead tr:first-child th,
  caption + tbody tr:first-child th,
  caption + tbody tr:first-child td,
  colgroup + thead tr:first-child th,
  colgroup + tbody tr:first-child th,
  colgroup + tbody tr:first-child td,
91
  thead:first-child tr:first-child th,
92
  tbody:first-child tr:first-child th,
93
  tbody:first-child tr:first-child td {
Mark Otto's avatar
Mark Otto committed
94
    border-top: 0;
95
  }
96
  // For first th or td in the first row in the first thead or tbody
Mark Otto's avatar
Mark Otto committed
97
98
  thead:first-child tr:first-child > th:first-child,
  tbody:first-child tr:first-child > td:first-child {
amid2887's avatar
amid2887 committed
99
    .border-top-left-radius(@baseBorderRadius);
100
  }
Mark Otto's avatar
Mark Otto committed
101
102
  thead:first-child tr:first-child > th:last-child,
  tbody:first-child tr:first-child > td:last-child {
amid2887's avatar
amid2887 committed
103
    .border-top-right-radius(@baseBorderRadius);
104
  }
amid2887's avatar
amid2887 committed
105
  // For first th or td in the last row in the last thead or tbody
Mark Otto's avatar
Mark Otto committed
106
107
108
  thead:last-child tr:last-child > th:first-child,
  tbody:last-child tr:last-child > td:first-child,
  tfoot:last-child tr:last-child > td:first-child {
amid2887's avatar
amid2887 committed
109
    .border-bottom-left-radius(@baseBorderRadius);
110
  }
Mark Otto's avatar
Mark Otto committed
111
112
113
  thead:last-child tr:last-child > th:last-child,
  tbody:last-child tr:last-child > td:last-child,
  tfoot:last-child tr:last-child > td:last-child {
amid2887's avatar
amid2887 committed
114
115
116
117
118
119
    .border-bottom-right-radius(@baseBorderRadius);
  }

  // Clear border-radius for first and last td in the last row in the last tbody for table with tfoot
  tfoot + tbody:last-child tr:last-child td:first-child {
    .border-bottom-left-radius(0);
120
  }
amid2887's avatar
amid2887 committed
121
122
123
124
  tfoot + tbody:last-child tr:last-child td:last-child {
    .border-bottom-right-radius(0);
  }

125

126
  // Special fixes to round the left border on the first td/th
127
128
129
130
  caption + thead tr:first-child th:first-child,
  caption + tbody tr:first-child td:first-child,
  colgroup + thead tr:first-child th:first-child,
  colgroup + tbody tr:first-child td:first-child {
amid2887's avatar
amid2887 committed
131
    .border-top-left-radius(@baseBorderRadius);
132
133
134
135
136
  }
  caption + thead tr:first-child th:last-child,
  caption + tbody tr:first-child td:last-child,
  colgroup + thead tr:first-child th:last-child,
  colgroup + tbody tr:first-child td:last-child {
amid2887's avatar
amid2887 committed
137
    .border-top-right-radius(@baseBorderRadius);
138
  }
139

Jacob Thornton's avatar
Jacob Thornton committed
140
141
}

142

143
144


145
146
147
148
// ZEBRA-STRIPING
// --------------

// Default zebra-stripe styles (alternating gray and transparent backgrounds)
149
.table-striped {
150
  tbody {
Mark Otto's avatar
Mark Otto committed
151
152
    > tr:nth-child(odd) > td,
    > tr:nth-child(odd) > th {
Mark Otto's avatar
Mark Otto committed
153
      background-color: @tableBackgroundAccent;
154
155
156
157
158
    }
  }
}


159
160
161
// HOVER EFFECT
// ------------
// Placed here since it has to come after the potential zebra striping
162
.table-hover {
163
164
165
166
167
  tbody {
    tr:hover td,
    tr:hover th {
      background-color: @tableBackgroundHover;
    }
168
169
170
  }
}

171

172
173
// TABLE CELL SIZING
// -----------------
174

175
// Reset default grid behavior
176
177
178
179
table td[class*="span"],
table th[class*="span"],
.row-fluid table td[class*="span"],
.row-fluid table th[class*="span"] {
180
181
182
183
184
185
  display: table-cell;
  float: none; // undo default grid column styles
  margin-left: 0; // undo default grid column styles
}

// Change the column widths to account for td/th padding
186
187
188
189
190
191
192
193
194
195
196
197
198
199
.table td,
.table th {
  &.span1     { .tableColumns(1); }
  &.span2     { .tableColumns(2); }
  &.span3     { .tableColumns(3); }
  &.span4     { .tableColumns(4); }
  &.span5     { .tableColumns(5); }
  &.span6     { .tableColumns(6); }
  &.span7     { .tableColumns(7); }
  &.span8     { .tableColumns(8); }
  &.span9     { .tableColumns(9); }
  &.span10    { .tableColumns(10); }
  &.span11    { .tableColumns(11); }
  &.span12    { .tableColumns(12); }
200
}
201
202


203

204
205
206
207
// TABLE BACKGROUNDS
// -----------------
// Exact selectors below required to override .table-striped

208
209
.table tbody tr {
  &.success td {
210
211
    background-color: @successBackground;
  }
212
  &.error td {
213
214
    background-color: @errorBackground;
  }
215
  &.warning td {
216
217
    background-color: @warningBackground;
  }
218
  &.info td {
219
220
221
    background-color: @infoBackground;
  }
}
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237

// Hover states for .table-hover
.table-hover tbody tr {
  &.success:hover td {
    background-color: darken(@successBackground, 5%);
  }
  &.error:hover td {
    background-color: darken(@errorBackground, 5%);
  }
  &.warning:hover td {
    background-color: darken(@warningBackground, 5%);
  }
  &.info:hover td {
    background-color: darken(@infoBackground, 5%);
  }
}