tables.less 3.69 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
tbody + tbody {
  border-top: 2px solid #ddd;
}
32
33


34
35
// CONDENSED TABLE W/ HALF PADDING
// -------------------------------
36
37
38
39

.condensed-table {
  th,
  td {
40
    padding: 4px 5px;
41
  }
42
43
44
45
46
47
48
49
50
51
}


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

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

83

84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// 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;
    }
  }
}



99
100
// TABLE CELL SIZING
// -----------------
101

102
// Change the columns
103
.tableColumns(@columnSpan: 1) {
104
105
106
  float: none;
  width: ((@gridColumnWidth) * @columnSpan) + (@gridGutterWidth * (@columnSpan - 1)) - 16;
  margin-left: 0;
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
}
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); }
}
122
123
124
125
126
127
128
129
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



// 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);
    }
  }
}