tables.less 4.31 KB
Newer Older
1
2
3
4
//
// Tables.less
// Tables for, you guessed it, tabular data
// ----------------------------------------
Jacob Thornton's avatar
Jacob Thornton committed
5

6

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

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

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

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

54
55


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

59
.table-condensed {
60
61
  th,
  td {
62
    padding: 4px 5px;
63
  }
64
65
66
67
68
69
}


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

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

121

122
123
124
125
// ZEBRA-STRIPING
// --------------

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


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

146

147
148
// TABLE CELL SIZING
// -----------------
149

150
// Change the columns
151
152
153
154
155
156
157
158
159
160
161
162
163
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); }
164
165
166
167
168
169
170
171
172
173
174
175
  .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); }
176
}