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

5

6
7
table {
  max-width: 100%;
Jacob Thornton's avatar
Jacob Thornton committed
8
  background-color: @tableBackground;
9
10
11
12
  border-collapse: collapse;
  border-spacing: 0;
}

13
14


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

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

52
53


54
55
// CONDENSED TABLE W/ HALF PADDING
// -------------------------------
56

57
.table-condensed {
58
59
  th,
  td {
60
    padding: 4px 5px;
61
  }
62
63
64
}


65

66
67
68
// BORDERED VERSION
// ----------------

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

119

120
  // Special fixes to round the left border on the first td/th
121
122
123
124
  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
125
    .border-top-left-radius(@baseBorderRadius);
126
127
128
129
130
  }
  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
131
    .border-top-right-radius(@baseBorderRadius);
132
  }
133

Jacob Thornton's avatar
Jacob Thornton committed
134
135
}

136

137

138
139
140
141
// ZEBRA-STRIPING
// --------------

// Default zebra-stripe styles (alternating gray and transparent backgrounds)
142
.table-striped {
143
144
145
  tbody {
    tr:nth-child(odd) td,
    tr:nth-child(odd) th {
Mark Otto's avatar
Mark Otto committed
146
      background-color: @tableBackgroundAccent;
147
148
149
150
151
    }
  }
}


152

153
154
155
// HOVER EFFECT
// ------------
// Placed here since it has to come after the potential zebra striping
156
.table-hover {
157
158
159
160
161
  tbody {
    tr:hover td,
    tr:hover th {
      background-color: @tableBackgroundHover;
    }
162
163
164
  }
}

165

166

167
168
// TABLE CELL SIZING
// -----------------
169

170
// Reset default grid behavior
171
172
173
174
table td[class*="span"],
table th[class*="span"],
.row-fluid table td[class*="span"],
.row-fluid table th[class*="span"] {
175
176
177
178
179
  display: table-cell;
  float: none; // undo default grid column styles
  margin-left: 0; // undo default grid column styles
}

180
181
182
183
// TABLE BACKGROUNDS
// -----------------
// Exact selectors below required to override .table-striped

184
185
.table tbody tr {
  &.success td {
186
187
    background-color: @successBackground;
  }
188
  &.error td {
189
190
    background-color: @errorBackground;
  }
191
  &.warning td {
192
193
    background-color: @warningBackground;
  }
194
  &.info td {
195
196
197
    background-color: @infoBackground;
  }
}
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213

// 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%);
  }
}