tables.less 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. //
  2. // Tables
  3. // --------------------------------------------------
  4. // BASE TABLES
  5. // -----------------
  6. table {
  7. max-width: 100%;
  8. background-color: @tableBackground;
  9. border-collapse: collapse;
  10. border-spacing: 0;
  11. }
  12. // BASELINE STYLES
  13. // ---------------
  14. .table {
  15. width: 100%;
  16. margin-bottom: @baseLineHeight;
  17. // Cells
  18. th,
  19. td {
  20. padding: 8px;
  21. line-height: @baseLineHeight;
  22. text-align: left;
  23. vertical-align: top;
  24. border-top: 1px solid @tableBorder;
  25. }
  26. th {
  27. font-weight: bold;
  28. }
  29. // Bottom align for column headings
  30. thead th {
  31. vertical-align: bottom;
  32. }
  33. // Remove top border from thead by default
  34. caption + thead tr:first-child th,
  35. caption + thead tr:first-child td,
  36. colgroup + thead tr:first-child th,
  37. colgroup + thead tr:first-child td,
  38. thead:first-child tr:first-child th,
  39. thead:first-child tr:first-child td {
  40. border-top: 0;
  41. }
  42. // Account for multiple tbody instances
  43. tbody + tbody {
  44. border-top: 2px solid @tableBorder;
  45. }
  46. }
  47. // CONDENSED TABLE W/ HALF PADDING
  48. // -------------------------------
  49. .table-condensed {
  50. th,
  51. td {
  52. padding: 4px 5px;
  53. }
  54. }
  55. // BORDERED VERSION
  56. // ----------------
  57. .table-bordered {
  58. border: 1px solid @tableBorder;
  59. border-collapse: separate; // Done so we can round those corners!
  60. *border-collapse: collapse; // IE7 can't round corners anyway
  61. border-left: 0;
  62. .border-radius(4px);
  63. th,
  64. td {
  65. border-left: 1px solid @tableBorder;
  66. }
  67. // Prevent a double border
  68. caption + thead tr:first-child th,
  69. caption + tbody tr:first-child th,
  70. caption + tbody tr:first-child td,
  71. colgroup + thead tr:first-child th,
  72. colgroup + tbody tr:first-child th,
  73. colgroup + tbody tr:first-child td,
  74. thead:first-child tr:first-child th,
  75. tbody:first-child tr:first-child th,
  76. tbody:first-child tr:first-child td {
  77. border-top: 0;
  78. }
  79. // For first th or td in the first row in the first thead or tbody
  80. thead:first-child tr:first-child th:first-child,
  81. tbody:first-child tr:first-child td:first-child {
  82. -webkit-border-top-left-radius: 4px;
  83. border-top-left-radius: 4px;
  84. -moz-border-radius-topleft: 4px;
  85. }
  86. thead:first-child tr:first-child th:last-child,
  87. tbody:first-child tr:first-child td:last-child {
  88. -webkit-border-top-right-radius: 4px;
  89. border-top-right-radius: 4px;
  90. -moz-border-radius-topright: 4px;
  91. }
  92. // For first th or td in the first row in the first thead or tbody
  93. thead:last-child tr:last-child th:first-child,
  94. tbody:last-child tr:last-child td:first-child,
  95. tfoot:last-child tr:last-child td:first-child {
  96. .border-radius(0 0 0 4px);
  97. -webkit-border-bottom-left-radius: 4px;
  98. border-bottom-left-radius: 4px;
  99. -moz-border-radius-bottomleft: 4px;
  100. }
  101. thead:last-child tr:last-child th:last-child,
  102. tbody:last-child tr:last-child td:last-child,
  103. tfoot:last-child tr:last-child td:last-child {
  104. -webkit-border-bottom-right-radius: 4px;
  105. border-bottom-right-radius: 4px;
  106. -moz-border-radius-bottomright: 4px;
  107. }
  108. // Special fixes to round the left border on the first td/th
  109. caption + thead tr:first-child th:first-child,
  110. caption + tbody tr:first-child td:first-child,
  111. colgroup + thead tr:first-child th:first-child,
  112. colgroup + tbody tr:first-child td:first-child {
  113. -webkit-border-top-left-radius: 4px;
  114. border-top-left-radius: 4px;
  115. -moz-border-radius-topleft: 4px;
  116. }
  117. caption + thead tr:first-child th:last-child,
  118. caption + tbody tr:first-child td:last-child,
  119. colgroup + thead tr:first-child th:last-child,
  120. colgroup + tbody tr:first-child td:last-child {
  121. -webkit-border-top-right-radius: 4px;
  122. border-top-right-radius: 4px;
  123. -moz-border-radius-topleft: 4px;
  124. }
  125. }
  126. // ZEBRA-STRIPING
  127. // --------------
  128. // Default zebra-stripe styles (alternating gray and transparent backgrounds)
  129. .table-striped {
  130. tbody {
  131. tr:nth-child(odd) td,
  132. tr:nth-child(odd) th {
  133. background-color: @tableBackgroundAccent;
  134. }
  135. }
  136. }
  137. // HOVER EFFECT
  138. // ------------
  139. // Placed here since it has to come after the potential zebra striping
  140. .table-hover {
  141. tbody {
  142. tr:hover td,
  143. tr:hover th {
  144. background-color: @tableBackgroundHover;
  145. }
  146. }
  147. }
  148. // TABLE CELL SIZING
  149. // -----------------
  150. // Reset default grid behavior
  151. table [class*=span],
  152. .row-fluid table [class*=span] {
  153. display: table-cell;
  154. float: none; // undo default grid column styles
  155. margin-left: 0; // undo default grid column styles
  156. }
  157. // Change the column widths to account for td/th padding
  158. .table {
  159. .span1 { .tableColumns(1); }
  160. .span2 { .tableColumns(2); }
  161. .span3 { .tableColumns(3); }
  162. .span4 { .tableColumns(4); }
  163. .span5 { .tableColumns(5); }
  164. .span6 { .tableColumns(6); }
  165. .span7 { .tableColumns(7); }
  166. .span8 { .tableColumns(8); }
  167. .span9 { .tableColumns(9); }
  168. .span10 { .tableColumns(10); }
  169. .span11 { .tableColumns(11); }
  170. .span12 { .tableColumns(12); }
  171. .span13 { .tableColumns(13); }
  172. .span14 { .tableColumns(14); }
  173. .span15 { .tableColumns(15); }
  174. .span16 { .tableColumns(16); }
  175. .span17 { .tableColumns(17); }
  176. .span18 { .tableColumns(18); }
  177. .span19 { .tableColumns(19); }
  178. .span20 { .tableColumns(20); }
  179. .span21 { .tableColumns(21); }
  180. .span22 { .tableColumns(22); }
  181. .span23 { .tableColumns(23); }
  182. .span24 { .tableColumns(24); }
  183. }
  184. // TABLE BACKGROUNDS
  185. // -----------------
  186. // Exact selectors below required to override .table-striped
  187. .table tbody tr {
  188. &.success td {
  189. background-color: @successBackground;
  190. }
  191. &.error td {
  192. background-color: @errorBackground;
  193. }
  194. &.warning td {
  195. background-color: @warningBackground;
  196. }
  197. &.info td {
  198. background-color: @infoBackground;
  199. }
  200. }
  201. // Hover states for .table-hover
  202. .table-hover tbody tr {
  203. &.success:hover td {
  204. background-color: darken(@successBackground, 5%);
  205. }
  206. &.error:hover td {
  207. background-color: darken(@errorBackground, 5%);
  208. }
  209. &.warning:hover td {
  210. background-color: darken(@warningBackground, 5%);
  211. }
  212. &.info:hover td {
  213. background-color: darken(@infoBackground, 5%);
  214. }
  215. }