_mixins.scss 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. @mixin icon($url, $width, $height: $width) {
  2. width: $width;
  3. height: $height;
  4. background: url(#{$url}) no-repeat;
  5. background-size: 100% 100%;
  6. }
  7. @mixin thin-border($position, $color: #d9d9d9, $size: 100%) {
  8. position: relative;
  9. @if $position == top or $position == bottom {
  10. &::before {
  11. content: '';
  12. position: absolute;
  13. left: 0;
  14. right: 0;
  15. #{$position}: 0;
  16. height: 0;
  17. border-bottom: 1PX solid $color;
  18. transform: scaleY(0.5);
  19. z-index: 1;
  20. }
  21. } @else {
  22. &::before {
  23. content: '';
  24. position: absolute;
  25. top: 50%;
  26. #{$position}: 0;
  27. width: 0;
  28. height: $size;
  29. border-left: 1PX solid $color;
  30. transform: translateY(-50%) scaleX(0.5);
  31. z-index: 1;
  32. }
  33. }
  34. }
  35. @mixin ellipsis($line: 1) {
  36. @if $line == 1 {
  37. white-space: nowrap;
  38. text-overflow: ellipsis;
  39. overflow: hidden;
  40. } @else {
  41. overflow: hidden;
  42. text-overflow: ellipsis;
  43. display: -webkit-box;
  44. -webkit-line-clamp: $line;
  45. -webkit-box-orient: vertical;
  46. }
  47. }
  48. $media-breakpoint-map: (
  49. sm: $breakpoint-sm,
  50. md: $breakpoint-md,
  51. lg: $breakpoint-lg,
  52. xl: $breakpoint-xl
  53. );
  54. @mixin media-breakpoint-up($size) {
  55. @media (min-width: map-get($media-breakpoint-map, $size)) {
  56. @content;
  57. }
  58. }
  59. @mixin media-breakpoint-down($size) {
  60. @media (max-width: map-get($media-breakpoint-map, $size) - 0.02) {
  61. @content;
  62. }
  63. }
  64. @mixin media-breakpoint-only($size) {
  65. @if $size == xs {
  66. @media (max-width: $breakpint-sm - 0.02) {
  67. @content;
  68. }
  69. } @else if $size == sm {
  70. @media (min-width: $breakpoint-sm) and (max-width: $breakpoint-md - 0.02) {
  71. @content;
  72. }
  73. } @else if $size == md {
  74. @media (min-width: $breakpoint-md) and (max-width: $breakpoint-lg - 0.02) {
  75. @content;
  76. }
  77. } @else if $size == lg {
  78. @media (min-width: $breakpoint-lg) and (max-width: $breakpoint-xl - 0.02) {
  79. @content;
  80. }
  81. } @else if $size == xl {
  82. @media (min-width: $breakpoint-xl) {
  83. @content;
  84. }
  85. }
  86. }