tables.less 5.48 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
57
58
59
60

  .success td {
    background-color: @successBackground;
  }
  .error td {
    background-color: @errorBackground;
  }
  .info td {
    background-color: @infoBackground;
  }
61
62
}

63
64


65
66
// CONDENSED TABLE W/ HALF PADDING
// -------------------------------
67

68
.table-condensed {
69
70
  th,
  td {
71
    padding: 4px 5px;
72
  }
73
74
75
76
77
78
}


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

79
.table-bordered {
Mark Otto's avatar
Mark Otto committed
80
  border: 1px solid @tableBorder;
81
  border-collapse: separate; // Done so we can round those corners!
82
  *border-collapse: collapse; // IE7 can't round corners anyway
Jacob Thornton's avatar
Jacob Thornton committed
83
  border-left: 0;
84
  .border-radius(4px);
85
86
  th,
  td {
Mark Otto's avatar
Mark Otto committed
87
    border-left: 1px solid @tableBorder;
88
  }
89
  // Prevent a double border
90
91
92
93
94
95
  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,
96
  thead:first-child tr:first-child th,
97
  tbody:first-child tr:first-child th,
98
  tbody:first-child tr:first-child td {
Mark Otto's avatar
Mark Otto committed
99
    border-top: 0;
100
  }
101
  // For first th or td in the first row in the first thead or tbody
102
103
  thead:first-child tr:first-child th:first-child,
  tbody:first-child tr:first-child td:first-child {
104
105
    -webkit-border-top-left-radius: 4px;
            border-top-left-radius: 4px;
Jacob Thornton's avatar
Jacob Thornton committed
106
        -moz-border-radius-topleft: 4px;
107
  }
108
109
  thead:first-child tr:first-child th:last-child,
  tbody:first-child tr:first-child td:last-child {
110
111
    -webkit-border-top-right-radius: 4px;
            border-top-right-radius: 4px;
Jacob Thornton's avatar
Jacob Thornton committed
112
        -moz-border-radius-topright: 4px;
113
  }
114
115
  // For first th or td in the first row in the first thead or tbody
  thead:last-child tr:last-child th:first-child,
116
117
  tbody:last-child tr:last-child td:first-child,
  tfoot:last-child tr:last-child td:first-child {
118
    .border-radius(0 0 0 4px);
119
120
    -webkit-border-bottom-left-radius: 4px;
            border-bottom-left-radius: 4px;
Jacob Thornton's avatar
Jacob Thornton committed
121
        -moz-border-radius-bottomleft: 4px;
122
  }
123
  thead:last-child tr:last-child th:last-child,
124
125
  tbody:last-child tr:last-child td:last-child,
  tfoot:last-child tr:last-child td:last-child {
126
127
    -webkit-border-bottom-right-radius: 4px;
            border-bottom-right-radius: 4px;
Jacob Thornton's avatar
Jacob Thornton committed
128
        -moz-border-radius-bottomright: 4px;
129
  }
130

131
  // Special fixes to round the left border on the first td/th
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
  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;
  }
148

Jacob Thornton's avatar
Jacob Thornton committed
149
150
}

151

152
153


154
155
156
157
// ZEBRA-STRIPING
// --------------

// Default zebra-stripe styles (alternating gray and transparent backgrounds)
158
.table-striped {
159
160
161
  tbody {
    tr:nth-child(odd) td,
    tr:nth-child(odd) th {
Mark Otto's avatar
Mark Otto committed
162
      background-color: @tableBackgroundAccent;
163
164
165
166
167
    }
  }
}


168
169
170
// HOVER EFFECT
// ------------
// Placed here since it has to come after the potential zebra striping
171
.table-hover {
172
173
  tbody tr:hover td,
  tbody tr:hover th {
Mark Otto's avatar
Mark Otto committed
174
    background-color: @tableBackgroundHover;
175
176
177
  }
}

178

179
180
// TABLE CELL SIZING
// -----------------
181

182
183
184
185
186
187
188
189
190
// 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
191
192
193
194
195
196
197
198
199
200
201
202
203
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); }
204
205
206
207
208
209
210
211
212
213
214
215
  .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); }
216
}