tables.less 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //
  2. // Tables.less
  3. // Tables for, you guessed it, tabular data
  4. // ----------------------------------------
  5. // BASE TABLES
  6. // -----------------
  7. table {
  8. max-width: 100%;
  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 #ddd;
  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. thead:first-child tr th,
  35. thead:first-child tr td {
  36. border-top: 0;
  37. }
  38. // Account for multiple tbody instances
  39. tbody + tbody {
  40. border-top: 2px solid #ddd;
  41. }
  42. }
  43. // CONDENSED TABLE W/ HALF PADDING
  44. // -------------------------------
  45. .table-condensed {
  46. th,
  47. td {
  48. padding: 4px 5px;
  49. }
  50. }
  51. // BORDERED VERSION
  52. // ----------------
  53. .table-bordered {
  54. border: 1px solid #ddd;
  55. border-collapse: separate; // Done so we can round those corners!
  56. *border-collapse: collapsed; // IE7 can't round corners anyway
  57. .border-radius(4px);
  58. th + th,
  59. td + td,
  60. th + td,
  61. td + th {
  62. border-left: 1px solid #ddd;
  63. }
  64. // Prevent a double border
  65. thead:first-child tr:first-child th,
  66. tbody:first-child tr:first-child th,
  67. tbody:first-child tr:first-child td {
  68. border-top: 0;
  69. }
  70. // For first th or td in the first row in the first thead or tbody
  71. thead:first-child tr:first-child th:first-child,
  72. tbody:first-child tr:first-child td:first-child {
  73. .border-radius(4px 0 0 0);
  74. }
  75. thead:first-child tr:first-child th:last-child,
  76. tbody:first-child tr:first-child td:last-child {
  77. .border-radius(0 4px 0 0);
  78. }
  79. // For first th or td in the first row in the first thead or tbody
  80. thead:last-child tr:last-child th:first-child,
  81. tbody:last-child tr:last-child td:first-child {
  82. .border-radius(0 0 0 4px);
  83. }
  84. thead:last-child tr:last-child th:last-child,
  85. tbody:last-child tr:last-child td:last-child {
  86. .border-radius(0 0 4px 0);
  87. }
  88. }
  89. // ZEBRA-STRIPING
  90. // --------------
  91. // Default zebra-stripe styles (alternating gray and transparent backgrounds)
  92. .table-striped {
  93. tbody {
  94. tr:nth-child(odd) td,
  95. tr:nth-child(odd) th {
  96. background-color: #f9f9f9;
  97. }
  98. }
  99. }
  100. // HOVER EFFECT
  101. // ------------
  102. // Placed here since it has to come after the potential zebra striping
  103. .table {
  104. tbody tr:hover td,
  105. tbody tr:hover th {
  106. background-color: #f5f5f5;
  107. }
  108. }
  109. // TABLE CELL SIZING
  110. // -----------------
  111. // Change the columns
  112. .tableColumns(@columnSpan: 1) {
  113. float: none;
  114. width: ((@gridColumnWidth) * @columnSpan) + (@gridGutterWidth * (@columnSpan - 1)) - 16;
  115. margin-left: 0;
  116. }
  117. table {
  118. .span1 { .tableColumns(1); }
  119. .span2 { .tableColumns(2); }
  120. .span3 { .tableColumns(3); }
  121. .span4 { .tableColumns(4); }
  122. .span5 { .tableColumns(5); }
  123. .span6 { .tableColumns(6); }
  124. .span7 { .tableColumns(7); }
  125. .span8 { .tableColumns(8); }
  126. .span9 { .tableColumns(9); }
  127. .span10 { .tableColumns(10); }
  128. .span11 { .tableColumns(11); }
  129. .span12 { .tableColumns(12); }
  130. }