helang-table10.scss 2.9 KB

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