table.scss 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. @import "mixins/mixins";
  2. @import "checkbox";
  3. @import "tag";
  4. @import "tooltip";
  5. @import "common/var";
  6. @include b(table) {
  7. position: relative;
  8. overflow: hidden;
  9. box-sizing: border-box;
  10. flex: 1;
  11. width: 100%;
  12. max-width: 100%;
  13. background-color: $--color-white;
  14. font-size: 14px;
  15. color: $--table-font-color;
  16. // 数据为空
  17. @include e(empty-block) {
  18. min-height: 60px;
  19. text-align: center;
  20. width: 100%;
  21. display: flex;
  22. justify-content: center;
  23. align-items: center;
  24. }
  25. @include e(empty-text) {
  26. // min-height doesn't work in IE10 and IE11 https://github.com/philipwalton/flexbugs#3-min-height-on-a-flex-container-wont-apply-to-its-flex-items
  27. // set empty text line height up to contrainer min-height as workaround.
  28. line-height: 60px;
  29. width: 50%;
  30. color: $--color-text-secondary;
  31. }
  32. // 展开行
  33. @include e(expand-column) {
  34. .cell {
  35. padding: 0;
  36. text-align: center;
  37. }
  38. }
  39. @include e(expand-icon) {
  40. position: relative;
  41. cursor: pointer;
  42. color: #666;
  43. font-size: 12px;
  44. transition: transform 0.2s ease-in-out;
  45. height: 20px;
  46. @include m(expanded) {
  47. transform: rotate(90deg);
  48. }
  49. > .el-icon {
  50. position: absolute;
  51. left: 50%;
  52. top: 50%;
  53. margin-left: -5px;
  54. margin-top: -5px;
  55. }
  56. }
  57. @include e(expanded-cell) {
  58. background-color: $--color-white;
  59. // 纯属为了增加权重
  60. &[class*=cell] {
  61. padding: 20px 50px;
  62. }
  63. &:hover {
  64. background-color: transparent !important;
  65. }
  66. }
  67. @include e(placeholder) {
  68. display: inline-block;
  69. width: 20px;
  70. }
  71. @include e(append-wrapper) {
  72. // 避免外边距重合 https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing
  73. overflow: hidden;
  74. }
  75. @include m(fit) {
  76. border-right: 0;
  77. border-bottom: 0;
  78. th.gutter, td.gutter {
  79. border-right-width: 1px;
  80. }
  81. }
  82. @include m(scrollable-x) {
  83. .el-table__body-wrapper {
  84. overflow-x: auto;
  85. }
  86. }
  87. @include m(scrollable-y) {
  88. .el-table__body-wrapper {
  89. overflow-y: auto;
  90. }
  91. }
  92. thead {
  93. color: $--table-header-font-color;
  94. font-weight: 500;
  95. &.is-group {
  96. th {
  97. background: $--background-color-base;
  98. }
  99. }
  100. }
  101. th, td {
  102. padding: 12px 0;
  103. min-width: 0;
  104. box-sizing: border-box;
  105. text-overflow: ellipsis;
  106. vertical-align: middle;
  107. position: relative;
  108. text-align: left;
  109. @include when(center) {
  110. text-align: center;
  111. }
  112. @include when(right) {
  113. text-align: right;
  114. }
  115. &.gutter {
  116. width: 15px;
  117. border-right-width: 0;
  118. border-bottom-width: 0;
  119. padding: 0;
  120. }
  121. &.is-hidden {
  122. > * {
  123. visibility: hidden;
  124. }
  125. }
  126. }
  127. @include m(medium) {
  128. th, td {
  129. padding: 10px 0;
  130. }
  131. }
  132. @include m(small) {
  133. font-size: 12px;
  134. th, td {
  135. padding: 8px 0;
  136. }
  137. }
  138. @include m(mini) {
  139. font-size: 12px;
  140. th, td {
  141. padding: 6px 0;
  142. }
  143. }
  144. tr {
  145. background-color: $--color-white;
  146. input[type="checkbox"] {
  147. margin: 0;
  148. }
  149. }
  150. th.is-leaf, td {
  151. border-bottom: $--table-border;
  152. }
  153. th.is-sortable {
  154. cursor: pointer;
  155. }
  156. th {
  157. overflow: hidden;
  158. user-select: none;
  159. background-color: $--table-header-background-color;
  160. > .cell {
  161. display: inline-block;
  162. box-sizing: border-box;
  163. position: relative;
  164. vertical-align: middle;
  165. padding-left: 10px;
  166. padding-right: 10px;
  167. width: 100%;
  168. &.highlight {
  169. color: $--color-primary;
  170. }
  171. }
  172. &.required > div::before {
  173. display: inline-block;
  174. content: "";
  175. width: 8px;
  176. height: 8px;
  177. border-radius: 50%;
  178. background: #ff4d51;
  179. margin-right: 5px;
  180. vertical-align: middle;
  181. }
  182. }
  183. td {
  184. div {
  185. box-sizing: border-box;
  186. }
  187. &.gutter {
  188. width: 0;
  189. }
  190. }
  191. .cell {
  192. box-sizing: border-box;
  193. overflow: hidden;
  194. text-overflow: ellipsis;
  195. white-space: normal;
  196. word-break: break-all;
  197. line-height: 23px;
  198. padding-left: 10px;
  199. padding-right: 10px;
  200. &.el-tooltip {
  201. white-space: nowrap;
  202. min-width: 50px;
  203. }
  204. }
  205. // 拥有多级表头
  206. @include m((group, border)) {
  207. border: $--table-border;
  208. @include share-rule(border-pseudo) {
  209. content: '';
  210. position: absolute;
  211. background-color: $--table-border-color;
  212. z-index: 1;
  213. }
  214. // 表格右部伪 border
  215. &::after {
  216. @include extend-rule(border-pseudo);
  217. top: 0;
  218. right: 0;
  219. width: 1px;
  220. height: 100%;
  221. }
  222. }
  223. // 表格底部伪 border,总是有的
  224. &::before {
  225. @include extend-rule(border-pseudo);
  226. left: 0;
  227. bottom: 0;
  228. width: 100%;
  229. height: 1px;
  230. }
  231. // table--border
  232. @include m(border) {
  233. border-right: none;
  234. border-bottom: none;
  235. &.el-loading-parent--relative {
  236. border-color: transparent;
  237. }
  238. th, td {
  239. border-right: $--table-border;
  240. &:first-child .cell {
  241. padding-left: 10px;
  242. }
  243. }
  244. th.gutter:last-of-type {
  245. border-bottom: $--table-border;
  246. border-bottom-width: 1px;
  247. }
  248. & th {
  249. border-bottom: $--table-border;
  250. }
  251. }
  252. @include m(hidden) {
  253. visibility: hidden;
  254. }
  255. @include e((fixed, fixed-right)) {
  256. position: absolute;
  257. top: 0;
  258. left: 0;
  259. overflow-x: hidden;
  260. overflow-y: hidden;
  261. box-shadow: $--table-fixed-box-shadow;
  262. &::before {
  263. content: '';
  264. position: absolute;
  265. left: 0;
  266. bottom: 0;
  267. width: 100%;
  268. height: 1px;
  269. background-color: $--border-color-lighter;
  270. z-index: 4;
  271. }
  272. }
  273. @include e(fixed-right-patch) {
  274. position: absolute;
  275. top: -1px;
  276. right: 0;
  277. background-color: $--color-white;
  278. border-bottom: $--table-border;
  279. }
  280. @include e(fixed-right) {
  281. top: 0;
  282. left: auto;
  283. right: 0;
  284. .el-table__fixed-header-wrapper,
  285. .el-table__fixed-body-wrapper,
  286. .el-table__fixed-footer-wrapper {
  287. left: auto;
  288. right: 0;
  289. }
  290. }
  291. @include e(fixed-header-wrapper) {
  292. position: absolute;
  293. left: 0;
  294. top: 0;
  295. z-index: 3;
  296. }
  297. @include e(fixed-footer-wrapper) {
  298. position: absolute;
  299. left: 0;
  300. bottom: 0;
  301. z-index: 3;
  302. & tbody td {
  303. border-top: $--table-border;
  304. background-color: $--table-row-hover-background-color;
  305. color: $--table-font-color;
  306. }
  307. }
  308. @include e(fixed-body-wrapper) {
  309. position: absolute;
  310. left: 0;
  311. top: 37px;
  312. overflow: hidden;
  313. z-index: 3;
  314. }
  315. @include e((header-wrapper, body-wrapper, footer-wrapper)) {
  316. width: 100%;
  317. }
  318. @include e(footer-wrapper) {
  319. margin-top: -1px;
  320. td {
  321. border-top: $--table-border;
  322. }
  323. }
  324. @include e((header, body, footer)) {
  325. table-layout: fixed;
  326. border-collapse: separate;
  327. }
  328. @include e((header-wrapper, footer-wrapper)) {
  329. overflow: hidden;
  330. & tbody td {
  331. background-color: $--table-row-hover-background-color;
  332. color: $--table-font-color;
  333. }
  334. }
  335. @include e(body-wrapper) {
  336. overflow: hidden;
  337. position: relative;
  338. @include when(scrolling-none) {
  339. ~ .el-table__fixed,
  340. ~ .el-table__fixed-right {
  341. box-shadow: none;
  342. }
  343. }
  344. @include when(scrolling-left) {
  345. ~ .el-table__fixed {
  346. box-shadow: none;
  347. }
  348. }
  349. @include when(scrolling-right) {
  350. ~ .el-table__fixed-right {
  351. box-shadow: none;
  352. }
  353. }
  354. .el-table--border {
  355. @include when(scrolling-right) {
  356. ~ .el-table__fixed-right {
  357. border-left: $--table-border;
  358. }
  359. }
  360. @include when(scrolling-left) {
  361. ~ .el-table__fixed {
  362. border-right: $--table-border;
  363. }
  364. }
  365. }
  366. }
  367. .caret-wrapper {
  368. display: inline-flex;
  369. flex-direction: column;
  370. align-items: center;
  371. height: 34px;
  372. width: 24px;
  373. vertical-align: middle;
  374. cursor: pointer;
  375. overflow: initial;
  376. position: relative;
  377. }
  378. .sort-caret {
  379. width: 0;
  380. height: 0;
  381. border: solid 5px transparent;
  382. position: absolute;
  383. left: 7px;
  384. &.ascending {
  385. border-bottom-color: $--color-text-placeholder;
  386. top: 5px;
  387. }
  388. &.descending {
  389. border-top-color: $--color-text-placeholder;
  390. bottom: 7px;
  391. }
  392. }
  393. .ascending .sort-caret.ascending {
  394. border-bottom-color: $--color-primary;
  395. }
  396. .descending .sort-caret.descending {
  397. border-top-color: $--color-primary;
  398. }
  399. .hidden-columns {
  400. visibility: hidden;
  401. position: absolute;
  402. z-index: -1;
  403. }
  404. @include m(striped) {
  405. & .el-table__body {
  406. & tr.el-table__row--striped {
  407. td {
  408. background: #FAFAFA;
  409. }
  410. &.current-row td {
  411. background-color: $--table-current-row-background-color;
  412. }
  413. }
  414. }
  415. }
  416. @include e(body) {
  417. tr.hover-row {
  418. &, &.el-table__row--striped {
  419. &, &.current-row {
  420. > td {
  421. background-color: $--table-row-hover-background-color;
  422. }
  423. }
  424. }
  425. }
  426. tr.current-row > td {
  427. background-color: $--table-current-row-background-color;
  428. }
  429. }
  430. @include e(column-resize-proxy) {
  431. position: absolute;
  432. left: 200px;
  433. top: 0;
  434. bottom: 0;
  435. width: 0;
  436. border-left: $--table-border;
  437. z-index: 10;
  438. }
  439. @include e(column-filter-trigger) {
  440. display: inline-block;
  441. line-height: 34px;
  442. cursor: pointer;
  443. & i {
  444. color: $--color-info;
  445. font-size: 12px;
  446. transform: scale(.75);
  447. }
  448. }
  449. @include m(enable-row-transition) {
  450. .el-table__body td {
  451. transition: background-color .25s ease;
  452. }
  453. }
  454. @include m(enable-row-hover) {
  455. .el-table__body tr:hover > td {
  456. background-color: $--table-row-hover-background-color;
  457. }
  458. }
  459. @include m(fluid-height) {
  460. .el-table__fixed,
  461. .el-table__fixed-right {
  462. bottom: 0;
  463. overflow: hidden;
  464. }
  465. }
  466. [class*=el-table__row--level] {
  467. .el-table__expand-icon {
  468. display: inline-block;
  469. width: 20px;
  470. line-height: 20px;
  471. height: 20px;
  472. text-align: center;
  473. margin-right: 3px;
  474. }
  475. }
  476. }