tables.less 5.6 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
  }
51
52
}

53
54


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

58
.table-condensed {
59
60
  th,
  td {
61
    padding: 4px 5px;
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!
72
  *border-collapse: collapse; // IE7 can't round corners anyway
Jacob Thornton's avatar
Jacob Thornton committed
73
  border-left: 0;
74
  .border-radius(4px);
75
76
  th,
  td {
Mark Otto's avatar
Mark Otto committed
77
    border-left: 1px solid @tableBorder;
78
  }
79
  // Prevent a double border
80
81
82
83
84
85
  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,
86
  thead:first-child tr:first-child th,
87
  tbody:first-child tr:first-child th,
88
  tbody:first-child tr:first-child td {
Mark Otto's avatar
Mark Otto committed
89
    border-top: 0;
90
  }
91
  // For first th or td in the first row in the first thead or tbody
92
93
  thead:first-child tr:first-child th:first-child,
  tbody:first-child tr:first-child td:first-child {
94
95
    -webkit-border-top-left-radius: 4px;
            border-top-left-radius: 4px;
Jacob Thornton's avatar
Jacob Thornton committed
96
        -moz-border-radius-topleft: 4px;
97
  }
98
99
  thead:first-child tr:first-child th:last-child,
  tbody:first-child tr:first-child td:last-child {
100
101
    -webkit-border-top-right-radius: 4px;
            border-top-right-radius: 4px;
Jacob Thornton's avatar
Jacob Thornton committed
102
        -moz-border-radius-topright: 4px;
103
  }
104
105
  // For first th or td in the first row in the first thead or tbody
  thead:last-child tr:last-child th:first-child,
106
107
  tbody:last-child tr:last-child td:first-child,
  tfoot:last-child tr:last-child td:first-child {
108
    .border-radius(0 0 0 4px);
109
110
    -webkit-border-bottom-left-radius: 4px;
            border-bottom-left-radius: 4px;
Jacob Thornton's avatar
Jacob Thornton committed
111
        -moz-border-radius-bottomleft: 4px;
112
  }
113
  thead:last-child tr:last-child th:last-child,
114
115
  tbody:last-child tr:last-child td:last-child,
  tfoot:last-child tr:last-child td:last-child {
116
117
    -webkit-border-bottom-right-radius: 4px;
            border-bottom-right-radius: 4px;
Jacob Thornton's avatar
Jacob Thornton committed
118
        -moz-border-radius-bottomright: 4px;
119
  }
120

121
  // Special fixes to round the left border on the first td/th
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
  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 {
    -webkit-border-top-left-radius: 4px;
            border-top-left-radius: 4px;
        -moz-border-radius-topleft: 4px;
  }
  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 {
    -webkit-border-top-right-radius: 4px;
            border-top-right-radius: 4px;
          -moz-border-right-topleft: 4px;
  }
138

Jacob Thornton's avatar
Jacob Thornton committed
139
140
}

141

142
143


144
145
146
147
// ZEBRA-STRIPING
// --------------

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


158
159
160
// HOVER EFFECT
// ------------
// Placed here since it has to come after the potential zebra striping
161
.table-hover {
162
163
  tr:hover td,
  tr:hover th {
Mark Otto's avatar
Mark Otto committed
164
    background-color: @tableBackgroundHover;
165
166
167
  }
}

168

169
170
// TABLE CELL SIZING
// -----------------
171

172
173
174
175
176
177
178
179
180
// Reset default grid behavior
table [class*=span],
.row-fluid table [class*=span] {
  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
181
182
183
184
185
186
187
188
189
190
191
192
193
table {
  .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); }
194
195
196
197
198
199
200
201
202
203
204
205
  .span13    { .tableColumns(13); }
  .span14    { .tableColumns(14); }
  .span15    { .tableColumns(15); }
  .span16    { .tableColumns(16); }
  .span17    { .tableColumns(17); }
  .span18    { .tableColumns(18); }
  .span19    { .tableColumns(19); }
  .span20    { .tableColumns(20); }
  .span21    { .tableColumns(21); }
  .span22    { .tableColumns(22); }
  .span23    { .tableColumns(23); }
  .span24    { .tableColumns(24); }
206
}
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223


// TABLE BACKGROUNDS
// -----------------
// Exact selectors below required to override .table-striped

.table {
  tbody tr.success td {
    background-color: @successBackground;
  }
  tbody tr.error td {
    background-color: @errorBackground;
  }
  tbody tr.info td {
    background-color: @infoBackground;
  }
}