tables.less 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. // Nesting
  47. .table {
  48. background-color: @bodyBackground;
  49. }
  50. }
  51. // CONDENSED TABLE W/ HALF PADDING
  52. // -------------------------------
  53. .table-condensed {
  54. th,
  55. td {
  56. padding: 4px 5px;
  57. }
  58. }
  59. // BORDERED VERSION
  60. // ----------------
  61. .table-bordered {
  62. border: 1px solid @tableBorder;
  63. border-collapse: separate; // Done so we can round those corners!
  64. *border-collapse: collapse; // IE7 can't round corners anyway
  65. border-left: 0;
  66. .border-radius(@baseBorderRadius);
  67. th,
  68. td {
  69. border-left: 1px solid @tableBorder;
  70. }
  71. // Prevent a double border
  72. caption + thead tr:first-child th,
  73. caption + tbody tr:first-child th,
  74. caption + tbody tr:first-child td,
  75. colgroup + thead tr:first-child th,
  76. colgroup + tbody tr:first-child th,
  77. colgroup + tbody tr:first-child td,
  78. thead:first-child tr:first-child th,
  79. tbody:first-child tr:first-child th,
  80. tbody:first-child tr:first-child td {
  81. border-top: 0;
  82. }
  83. // For first th or td in the first row in the first thead or tbody
  84. thead:first-child tr:first-child > th:first-child,
  85. tbody:first-child tr:first-child > td:first-child {
  86. .border-top-left-radius(@baseBorderRadius);
  87. }
  88. thead:first-child tr:first-child > th:last-child,
  89. tbody:first-child tr:first-child > td:last-child {
  90. .border-top-right-radius(@baseBorderRadius);
  91. }
  92. // For first th or td in the last row in the last 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-bottom-left-radius(@baseBorderRadius);
  97. }
  98. thead:last-child tr:last-child > th:last-child,
  99. tbody:last-child tr:last-child > td:last-child,
  100. tfoot:last-child tr:last-child > td:last-child {
  101. .border-bottom-right-radius(@baseBorderRadius);
  102. }
  103. // Clear border-radius for first and last td in the last row in the last tbody for table with tfoot
  104. tfoot + tbody:last-child tr:last-child td:first-child {
  105. .border-bottom-left-radius(0);
  106. }
  107. tfoot + tbody:last-child tr:last-child td:last-child {
  108. .border-bottom-right-radius(0);
  109. }
  110. // Special fixes to round the left border on the first td/th
  111. caption + thead tr:first-child th:first-child,
  112. caption + tbody tr:first-child td:first-child,
  113. colgroup + thead tr:first-child th:first-child,
  114. colgroup + tbody tr:first-child td:first-child {
  115. .border-top-left-radius(@baseBorderRadius);
  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. .border-top-right-radius(@baseBorderRadius);
  122. }
  123. }
  124. // ZEBRA-STRIPING
  125. // --------------
  126. // Default zebra-stripe styles (alternating gray and transparent backgrounds)
  127. .table-striped {
  128. tbody {
  129. > tr:nth-child(odd) > td,
  130. > tr:nth-child(odd) > th {
  131. background-color: @tableBackgroundAccent;
  132. }
  133. }
  134. }
  135. // HOVER EFFECT
  136. // ------------
  137. // Placed here since it has to come after the potential zebra striping
  138. .table-hover {
  139. tbody {
  140. tr:hover td,
  141. tr:hover th {
  142. background-color: @tableBackgroundHover;
  143. }
  144. }
  145. }
  146. // TABLE CELL SIZING
  147. // -----------------
  148. // Reset default grid behavior
  149. table td[class*="span"],
  150. table th[class*="span"],
  151. .row-fluid table td[class*="span"],
  152. .row-fluid table th[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 td,
  159. .table th {
  160. &.span1 { .tableColumns(1); }
  161. &.span2 { .tableColumns(2); }
  162. &.span3 { .tableColumns(3); }
  163. &.span4 { .tableColumns(4); }
  164. &.span5 { .tableColumns(5); }
  165. &.span6 { .tableColumns(6); }
  166. &.span7 { .tableColumns(7); }
  167. &.span8 { .tableColumns(8); }
  168. &.span9 { .tableColumns(9); }
  169. &.span10 { .tableColumns(10); }
  170. &.span11 { .tableColumns(11); }
  171. &.span12 { .tableColumns(12); }
  172. }
  173. // TABLE BACKGROUNDS
  174. // -----------------
  175. // Exact selectors below required to override .table-striped
  176. .table tbody tr {
  177. &.success td {
  178. background-color: @successBackground;
  179. }
  180. &.error td {
  181. background-color: @errorBackground;
  182. }
  183. &.warning td {
  184. background-color: @warningBackground;
  185. }
  186. &.info td {
  187. background-color: @infoBackground;
  188. }
  189. }
  190. // Hover states for .table-hover
  191. .table-hover tbody tr {
  192. &.success:hover td {
  193. background-color: darken(@successBackground, 5%);
  194. }
  195. &.error:hover td {
  196. background-color: darken(@errorBackground, 5%);
  197. }
  198. &.warning:hover td {
  199. background-color: darken(@warningBackground, 5%);
  200. }
  201. &.info:hover td {
  202. background-color: darken(@infoBackground, 5%);
  203. }
  204. }