mixin.scss 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * 混入定义
  3. *
  4. * @since 1.0.0
  5. * @version 1.0.0
  6. */
  7. /* 定义1px边框 */
  8. @mixin border-side($side-list, $color, $width: 1) {
  9. /* todo 抛出错误,提示,未定义颜色值 */
  10. $top: '';
  11. $bottom: '';
  12. $left: '';
  13. $right: '';
  14. $image-url: '';
  15. @each $side, $index in $side-list {
  16. @if ($side == t) {
  17. $top: "<line x1='0%' y1='0%' x2='100%' y2='0%' style='stroke:" + $color + ';stroke-width:' + $width + "' />";
  18. }
  19. @if ($side == b) {
  20. $bottom: "<line x1='0%' y1='100%' x2='100%' y2='100%' style='stroke:" +
  21. $color +
  22. ';stroke-width:' +
  23. $width +
  24. "' />";
  25. }
  26. @if ($side == l) {
  27. $left: "<line x1='0%' y1='0%' x2='0%' y2='100%' style='stroke:" + $color + ';stroke-width:' + $width + "' />";
  28. }
  29. @if ($side == r) {
  30. $right: "<line x1='100%' y1='0%' x2='100%' y2='100%' style='stroke:" +
  31. $color +
  32. ';stroke-width:' +
  33. $width +
  34. "' />";
  35. }
  36. background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%'> " + $top + $bottom + $left + $right + ' </svg>');
  37. }
  38. }
  39. /* 构建边框序列 */
  40. @mixin generate-border($side-list, $color) {
  41. .#{$ui-border}.#{$side-list} {
  42. @include border-side(t b l r, $color);
  43. }
  44. .#{$ui-border + '-t'}.#{$side-list} {
  45. @include border-side(t, $color);
  46. }
  47. .#{$ui-border + '-b'}.#{$side-list} {
  48. @include border-side(b, $color);
  49. }
  50. .#{$ui-border + '-l'}.#{$side-list} {
  51. @include border-side(l, $color);
  52. }
  53. .#{$ui-border + '-r'}.#{$side-list} {
  54. @include border-side(r, $color);
  55. }
  56. }
  57. /* 多行文本省略,默认省略单行 */
  58. @mixin text-overflow($len: 1) {
  59. @if $len == 1 {
  60. display: block;
  61. white-space: nowrap;
  62. text-overflow: ellipsis;
  63. overflow: hidden;
  64. } @else {
  65. display: -webkit-box;
  66. -webkit-box-orient: vertical;
  67. -webkit-line-clamp: $len;
  68. overflow: hidden;
  69. }
  70. }