helang-table.scss 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * uni-app 表格样式表
  3. * 作者:helang
  4. * 邮箱:helang.love@qq.com
  5. */
  6. .h-table{
  7. /* 行 */
  8. .h-tr{
  9. box-sizing: border-box;
  10. display: flex;
  11. flex-direction: row;
  12. flex-wrap: nowrap;
  13. justify-content: flex-start;
  14. align-items: stretch;
  15. align-content: center;
  16. border-color: #ccc;
  17. border-style: solid;
  18. border-width: 0;
  19. border-top-width: 1px;
  20. border-left-width: 1px;
  21. border-bottom-width: 1px;
  22. color: #333;
  23. /* 等比分列,1-8列 */
  24. @for $i from 1 through 8
  25. {
  26. &-#{$i}{
  27. >.h-td{
  28. width:(100% / $i);
  29. }
  30. }
  31. }
  32. + .h-tr{
  33. border-top-style: none;
  34. }
  35. }
  36. /* 单元格 */
  37. .h-td{
  38. box-sizing: border-box;
  39. padding: 3px;
  40. word-break:break-all;
  41. border-color: #ccc;
  42. border-style: solid;
  43. border-width: 0;
  44. border-right-width: 1px;
  45. display: flex;
  46. flex-direction: row;
  47. flex-wrap: nowrap;
  48. justify-content: center;
  49. align-items: center;
  50. align-content: center;
  51. min-height: 30rpx;
  52. /* 跨列 */
  53. &-colspan{
  54. flex-grow: 1;
  55. width:0;
  56. }
  57. &-rowspan{
  58. // border: none;
  59. border-right-width: 0;
  60. padding: 0 !important;
  61. flex-wrap: wrap !important;
  62. >.h-tr{
  63. width: 100%;
  64. border-width: 0;
  65. .h-td{
  66. border-right-width: 1px;
  67. }
  68. & + .h-tr{
  69. border-top-width: 1px;
  70. border-top-style: solid;
  71. }
  72. }
  73. }
  74. /* 内容顶部对齐 */
  75. &-top{
  76. align-items: flex-start;
  77. align-content:flex-start;
  78. }
  79. /* 内容底部对齐 */
  80. &-bottom{
  81. align-items: flex-end;
  82. align-content:flex-end;
  83. }
  84. /* 内容左边对齐 */
  85. &-left{
  86. justify-content: flex-start;
  87. }
  88. /* 内容右边对齐 */
  89. &-right{
  90. justify-content: flex-end;
  91. }
  92. }
  93. /* 表头 */
  94. .h-thead{
  95. background-color: #e6e6e6;
  96. }
  97. /* 表格虚线 */
  98. &-dashed{
  99. .h-tr{
  100. border-top-style: dashed;
  101. border-left-style: dashed;
  102. border-bottom-style: dashed;
  103. }
  104. .h-td{
  105. border-right-style: dashed;
  106. }
  107. .h-td-rowspan{
  108. .h-tr + .h-tr{
  109. border-top-style: dashed;
  110. }
  111. }
  112. }
  113. /* 表格主题 Map,颜色摘自 Bootstrap */
  114. $theme-table:(
  115. primary:(
  116. color:#fff,
  117. bgColor:#337ab7,
  118. border:#2e6da4
  119. ),
  120. success:(
  121. color:#fff,
  122. bgColor:#5cb85c,
  123. border:#4cae4c
  124. ),
  125. info:(
  126. color:#fff,
  127. bgColor:#5bc0de,
  128. border:#46b8da
  129. ),
  130. warning:(
  131. color:#fff,
  132. bgColor:#f0ad4e,
  133. border:#eea236
  134. ),
  135. danger:(
  136. color:#fff,
  137. bgColor:#d9534f,
  138. border:#d43f3a
  139. )
  140. );
  141. /* 生成主题代码 */
  142. $theme-table-keys:map-keys($theme-table);
  143. @each $k in $theme-table-keys {
  144. $item:map-get($theme-table,$k);
  145. &-#{$k}{
  146. .h-tr{
  147. border-top-color: map-get($item,border);
  148. border-left-color: map-get($item,border);
  149. border-bottom-color: map-get($item,border);
  150. color: map-get($item,bgColor);
  151. }
  152. .h-td{
  153. border-right-color: map-get($item,border);
  154. }
  155. .h-thead{
  156. background-color: map-get($item,bgColor);
  157. color: map-get($item,color);
  158. }
  159. }
  160. }
  161. }