mixin.scss 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*圆角*/
  2. @mixin border-radius($radius...) {
  3. -webkit-border-radius: $radius;
  4. -moz-border-radius: $radius;
  5. -o-border-radius: $radius;
  6. border-radius: $radius;
  7. }
  8. /*阴影*/
  9. @mixin box-shadow($shadows...) {
  10. -moz-box-shadow: $shadows;
  11. -webkit-box-shadow: $shadows;
  12. box-shadow: $shadows;
  13. }
  14. /*文字阴影*/
  15. @mixin text-shadow($shadows...){
  16. text-shadow:$shadows;
  17. }
  18. /*线性渐变*/
  19. @mixin linear-gradient($val...){
  20. background: -webkit-linear-gradient($val); /* Safari 5.1 - 6.0 */
  21. background: -o-linear-gradient($val); /* Opera 11.1 - 12.0 */
  22. background: -moz-linear-gradient($val); /* Firefox 3.6 - 15 */
  23. background: linear-gradient($val); /* 标准的语法 */
  24. }
  25. /*垂直居中*/
  26. @mixin vertical-center() {
  27. display: -webkit-flex;
  28. display: flex;
  29. -webkit-align-items: center;
  30. align-items: center;
  31. -webkit-justify-content: center;
  32. justify-content: center;
  33. }
  34. /*去除padding 宽度*/
  35. @mixin box-sizing-border() {
  36. box-sizing: border-box;
  37. -moz-box-sizing: border-box;
  38. /* Firefox */
  39. -webkit-box-sizing: border-box;
  40. /* Safari */
  41. }
  42. /*css3盒子
  43. * flex-direction: row row-reverse column column-reverse
  44. * flex-wrap: nowrap wrap wrap-reverse
  45. * justify-content: flex-start flex-end center space-between space-around
  46. * align-items: stretch flex-start flex-end center beseline
  47. * align-content: stretch flex-start flex-end center space-between space-around
  48. * */
  49. @mixin display-flex() {
  50. display: -webkit-flex;
  51. display: flex;
  52. }
  53. @mixin flex-direction($value) {
  54. @include display-flex();
  55. -webkit-flex-direction: $value;
  56. flex-direction: $value;
  57. }
  58. @mixin flex-wrap($value) {
  59. @include display-flex();
  60. -webkit-flex-wrap: $value;
  61. flex-wrap: $value;
  62. }
  63. @mixin justify-content($value) {
  64. @include display-flex();
  65. -webkit-justify-content: $value;
  66. justify-content: $value;
  67. }
  68. @mixin align-items($value) {
  69. @include display-flex();
  70. -webkit-align-items: $value;
  71. align-items: $value;
  72. }
  73. @mixin align-content($value) {
  74. @include display-flex();
  75. -webkit-align-content: $value;
  76. align-content: $value;
  77. }
  78. /*设置flex*/
  79. @mixin flex-num($num) {
  80. -webkit-box-flex: $num;
  81. -ms-flex: $num;
  82. flex: $num;
  83. }
  84. /*一行截取*/
  85. @mixin ellipsis() {
  86. overflow: hidden;
  87. text-overflow: ellipsis;
  88. white-space: nowrap;
  89. }
  90. /*多行截取*/
  91. @mixin ellipsis-clamp($num) {
  92. text-overflow: ellipsis;
  93. overflow: hidden;
  94. display: -webkit-box;
  95. -webkit-line-clamp: $num;
  96. -webkit-box-orient: vertical;
  97. word-break: break-all;
  98. }
  99. /*旋转角度,x,y位移*/
  100. @mixin rotate-origin($num, $x, $y) {
  101. transform: rotate($num);
  102. transform-origin: $x $y;
  103. -ms-transform: rotate($num);
  104. /* IE 9 */
  105. -ms-transform-origin: $x $y;
  106. /* IE 9 */
  107. -webkit-transform: rotate($num);
  108. /* Safari and Chrome */
  109. -webkit-transform-origin: $x $y;
  110. /* Safari and Chrome */
  111. }
  112. /*旋转*/
  113. @mixin transform-rotate($deg){
  114. transform: rotate($deg);
  115. -ms-transform: rotate($deg); /* IE 9 */
  116. -webkit-transform: rotate($deg); /* Safari and Chrome */
  117. }
  118. /*过度*/
  119. @mixin transition($val...){
  120. transition: $val;
  121. -webkit-transition: $val; /* Safari */
  122. }
  123. /*模糊*/
  124. @mixin filter($val...){
  125. -webkit-filter: blur($val);
  126. filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius='1');
  127. }