tables.less 4.51 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: collapsed; // 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
106
  // For first th or td in the first row in the first thead or tbody
  thead:last-child tr:last-child th:first-child,
  tbody:last-child tr:last-child td:first-child {
107
    .border-radius(0 0 0 4px);
108
109
    -webkit-border-bottom-left-radius: 4px;
            border-bottom-left-radius: 4px;
Jacob Thornton's avatar
Jacob Thornton committed
110
        -moz-border-radius-bottomleft: 4px;
111
  }
112
113
  thead:last-child tr:last-child th:last-child,
  tbody:last-child tr:last-child td:last-child {
114
115
    -webkit-border-bottom-right-radius: 4px;
            border-bottom-right-radius: 4px;
Jacob Thornton's avatar
Jacob Thornton committed
116
        -moz-border-radius-bottomright: 4px;
117
  }
Jacob Thornton's avatar
Jacob Thornton committed
118
119
}

120

121
122
123
124
// ZEBRA-STRIPING
// --------------

// Default zebra-stripe styles (alternating gray and transparent backgrounds)
125
.table-striped {
126
127
128
  tbody {
    tr:nth-child(odd) td,
    tr:nth-child(odd) th {
Mark Otto's avatar
Mark Otto committed
129
      background-color: @tableBackgroundAccent;
130
131
132
133
134
    }
  }
}


135
136
137
// HOVER EFFECT
// ------------
// Placed here since it has to come after the potential zebra striping
138
.table-hover {
139
140
  tbody tr:hover td,
  tbody tr:hover th {
Mark Otto's avatar
Mark Otto committed
141
    background-color: @tableBackgroundHover;
142
143
144
  }
}

145

146
147
// TABLE CELL SIZING
// -----------------
148

149
150
151
152
153
154
155
156
157
// 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
158
159
160
161
162
163
164
165
166
167
168
169
170
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); }
171
172
173
174
175
176
177
178
179
180
181
182
  .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); }
183
}