halfline.scss 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /**
  2. * 默认主题下 $color-border-light
  3. */
  4. $color-border-light: #979797;
  5. @mixin hairline-common() {
  6. content: "";
  7. position: absolute;
  8. transform-origin: center;
  9. box-sizing: border-box;
  10. pointer-events: none;
  11. }
  12. @mixin hairline-base($color: $color-border-light, $style: solid) {
  13. @include hairline-common();
  14. top: -50%;
  15. left: -50%;
  16. right: -50%;
  17. bottom: -50%;
  18. border: 0 $style $color;
  19. transform: scale(0.5);
  20. }
  21. @mixin hairline-surround(
  22. $color: $color-border-light,
  23. $style: solid,
  24. $width: 1px
  25. ) {
  26. position: relative;
  27. &::after {
  28. @include hairline-base($color, $style);
  29. border-width: $width;
  30. }
  31. }
  32. @mixin hairline-top($color: $color-border-light, $style: solid, $width: 1px) {
  33. position: relative;
  34. &::after {
  35. @include hairline-base($color, $style);
  36. border-top-width: $width;
  37. }
  38. }
  39. @mixin hairline-bottom(
  40. $color: $color-border-light,
  41. $style: solid,
  42. $width: 1px
  43. ) {
  44. position: relative;
  45. &::after {
  46. @include hairline-base($color, $style);
  47. border-bottom-width: $width;
  48. }
  49. }
  50. @mixin hairline-left($color: $color-border-light, $style: solid, $width: 1px) {
  51. position: relative;
  52. &::after {
  53. @include hairline-base($color, $style);
  54. border-left-width: $width;
  55. }
  56. }
  57. @mixin hairline-right($color: $color-border-light, $style: solid, $width: 1px) {
  58. position: relative;
  59. &::after {
  60. @include hairline-base($color, $style);
  61. border-right-width: $width;
  62. }
  63. }
  64. @mixin hairline-top-bottom(
  65. $color: $color-border-light,
  66. $style: solid,
  67. $width: 1px
  68. ) {
  69. position: relative;
  70. &::after {
  71. @include hairline-base($color, $style);
  72. border-top-width: $width;
  73. border-bottom-width: $width;
  74. }
  75. }
  76. @mixin hairline-bottom-relative(
  77. $color: $color-border-light,
  78. $style: solid,
  79. $width: 1px,
  80. $left: 0
  81. ) {
  82. position: relative;
  83. &::after {
  84. @include hairline-common();
  85. top: auto;
  86. left: $left;
  87. right: 0;
  88. bottom: 0;
  89. transform: scaleY(0.5);
  90. border-bottom: $width $style $color;
  91. }
  92. }
  93. @mixin hairline-top-relative(
  94. $color: $color-border-light,
  95. $style: solid,
  96. $width: 1px,
  97. $left: 0
  98. ) {
  99. position: relative;
  100. &::before {
  101. @include hairline-common();
  102. top: 0;
  103. left: $left;
  104. right: 0;
  105. bottom: auto;
  106. transform: scaleY(0.5);
  107. border-top: $width $style $color;
  108. }
  109. }
  110. @mixin hairline-left-relative(
  111. $color: $color-border-light,
  112. $style: solid,
  113. $width: 1px,
  114. $top: 0
  115. ) {
  116. position: relative;
  117. &::after {
  118. @include hairline-common();
  119. top: $top;
  120. left: 0;
  121. right: auto;
  122. bottom: 0;
  123. transform: scaleX(0.5);
  124. border-left: $width $style $color;
  125. }
  126. }
  127. @mixin hairline-right-relative(
  128. $color: $color-border-light,
  129. $style: solid,
  130. $width: 1px,
  131. $top: 0
  132. ) {
  133. position: relative;
  134. &::after {
  135. @include hairline-common();
  136. top: $top;
  137. left: auto;
  138. right: 0;
  139. bottom: 0;
  140. transform: scaleX(0.5);
  141. border-right: $width $style $color;
  142. }
  143. }
  144. @mixin line($num: 1) {
  145. overflow: hidden;
  146. text-overflow: ellipsis;
  147. @if ($num == 1) {
  148. white-space: nowrap;
  149. } @else {
  150. display: -webkit-box;
  151. -webkit-line-clamp: $num;
  152. /* autoprefixer: off */
  153. -webkit-box-orient: vertical;
  154. }
  155. }
  156. /**
  157. * 点击态
  158. */
  159. @mixin active {
  160. transition: background-color 0.3s;
  161. &:active {
  162. background-color: #f2f2f2;
  163. }
  164. }