tables.less 3.84 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
// BASELINE STYLES
// ---------------
Jacob Thornton's avatar
Jacob Thornton committed
10
11
12

table {
  width: 100%;
13
  margin-bottom: @baseLineHeight;
14
15
16
17
18
19
}
th,
td {
  padding: 8px;
  line-height: @baseLineHeight;
  text-align: left;
20
  border-top: 1px solid #ddd;
21
22
23
24
25
26
27
28
}
th {
  font-weight: bold;
  vertical-align: bottom;
}
td {
  vertical-align: top;
}
29
30
31
32
33
34
35
36

// Remove top border from thead by default
thead:first-child tr th,
thead:first-child tr td {
  border-top: 0;
}

// Account for multiple tbody instances
37
38
39
tbody + tbody {
  border-top: 2px solid #ddd;
}
40
41


42
43
// CONDENSED TABLE W/ HALF PADDING
// -------------------------------
44
45
46
47

.condensed-table {
  th,
  td {
48
    padding: 4px 5px;
49
  }
50
51
52
53
54
55
56
57
58
59
}


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

.bordered-table {
  border: 1px solid #ddd;
  border-collapse: separate; // Done so we can round those corners!
  .border-radius(4px);
60
  th + th,
61
  td + td,
62
63
  th + td,
  td + th {
64
65
    border-left: 1px solid #ddd;
  }
66
67
68
69
70
  // Prevent a double border
  thead:first-child tr:first-child th,
  tbody:first-child tr:first-child td {
    border-top: 0;
  }
71
  // For first th or td in the first row in the first thead or tbody
72
73
  thead:first-child tr:first-child th:first-child,
  tbody:first-child tr:first-child td:first-child {
74
75
    .border-radius(4px 0 0 0);
  }
76
77
  thead:first-child tr:first-child th:last-child,
  tbody:first-child tr:first-child td:last-child {
78
79
    .border-radius(0 4px 0 0);
  }
80
81
82
  // 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 {
83
84
    .border-radius(0 0 0 4px);
  }
85
86
  thead:last-child tr:last-child th:last-child,
  tbody:last-child tr:last-child td:last-child {
87
88
    .border-radius(0 0 4px 0);
  }
Jacob Thornton's avatar
Jacob Thornton committed
89
90
}

91

92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// ZEBRA-STRIPING
// --------------

// Default zebra-stripe styles (alternating gray and transparent backgrounds)
.striped-table {
  tbody {
    tr:nth-child(odd) td,
    tr:nth-child(odd) th {
      background-color: #f9f9f9;
    }
  }
}



107
108
// TABLE CELL SIZING
// -----------------
109

110
// Change the columns
111
.tableColumns(@columnSpan: 1) {
112
113
114
  float: none;
  width: ((@gridColumnWidth) * @columnSpan) + (@gridGutterWidth * (@columnSpan - 1)) - 16;
  margin-left: 0;
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
}
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); }
}
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183



// TABLESORTER
// -----------
// Support for the tablesorter jQuerdy plugin

table {
  // Tablesorting styles w/ jQuery plugin
  .header {
    cursor: pointer;
    &:after {
      content: "";
      float: right;
      margin-top: 7px;
      border-width: 0 4px 4px;
      border-style: solid;
      border-color: #000 transparent;
      visibility: hidden;
    }
  }
  // Style the sorted column headers (THs)
  .headerSortUp,
  .headerSortDown {
    background-color: rgba(141,192,219,.25);
    text-shadow: 0 1px 1px rgba(255,255,255,.75);
  }
  // Style the ascending (reverse alphabetical) column header
  .header:hover {
    &:after {
      visibility:visible;
    }
  }
  // Style the descending (alphabetical) column header
  .headerSortDown,
  .headerSortDown:hover {
    &:after {
      visibility:visible;
      .opacity(60);
    }
  }
  // Style the ascending (reverse alphabetical) column header
  .headerSortUp {
    &:after {
      border-bottom: none;
      border-left: 4px solid transparent;
      border-right: 4px solid transparent;
      border-top: 4px solid #000;
      visibility:visible;
      .box-shadow(none); //can't add boxshadow to downward facing arrow :(
      .opacity(60);
    }
  }
}