tables.less 3.67 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
12
13
// BASE TABLES
// -----------------

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

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

106

107
108
109
110
// ZEBRA-STRIPING
// --------------

// Default zebra-stripe styles (alternating gray and transparent backgrounds)
111
.table-striped {
112
113
114
  tbody {
    tr:nth-child(odd) td,
    tr:nth-child(odd) th {
Mark Otto's avatar
Mark Otto committed
115
      background-color: @tableBackgroundAccent;
116
117
118
119
120
    }
  }
}


121
122
123
124
125
126
// HOVER EFFECT
// ------------
// Placed here since it has to come after the potential zebra striping
.table {
  tbody tr:hover td,
  tbody tr:hover th {
Mark Otto's avatar
Mark Otto committed
127
    background-color: @tableBackgroundHover;
128
129
130
  }
}

131

132
133
// TABLE CELL SIZING
// -----------------
134

135
// Change the columns
136
137
138
139
140
141
142
143
144
145
146
147
148
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); }
149
150
151
152
153
154
155
156
157
158
159
160
  .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); }
161
}