_btn.scss 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // 按钮组件样式复用
  2. /**
  3. * [btn-bg 按钮样式复用,包含默认、移入、点击样式交互]
  4. * @param {[string]} $bgc [eg:#fff,可选参]
  5. * @param {[string]} $percent [eg:10%,可选参]
  6. */
  7. @mixin btn-bg($bgc: #4790d0, $percent: 10%) {
  8. background-color: $bgc;
  9. &:hover {
  10. background-color: lighten($bgc, $percent);
  11. }
  12. &:active {
  13. background-color: darken($bgc, $percent);
  14. }
  15. }
  16. @mixin box-shadow($x, $y, $w, $b, $rgba) {
  17. -webkit-box-shadow: $x $y $w $b $rgba;
  18. -moz-box-shadow: $x $y $w $b $rgba;
  19. box-shadow: $x $y $w $b $rgba;
  20. }
  21. @mixin transition($prop, $dur, $timingfun: linear) {
  22. -webkit-transition: $prop $dur $timingfun;
  23. -moz-transition: $prop $dur $timingfun;
  24. -o-transition: $prop $dur $timingfun;
  25. transition: $prop $dur $timingfun;
  26. }
  27. /* 边框颜色变化*/
  28. @mixin btn-bor($bor: #4790d0, $pre: 10%) {
  29. &:hover {
  30. border-color: $bor;
  31. color: $bor;
  32. }
  33. &:active {
  34. border-color: darken($bor, $pre);
  35. color: darken($bor, $pre);
  36. }
  37. }
  38. /* 字体和背景色互换*/
  39. @mixin btn-bg-cor($bgc: #fff, $cor: #f04134, $pre: 5%) {
  40. color: $cor;
  41. background-color: $bgc;
  42. &:hover {
  43. color: $bgc;
  44. background-color: $cor;
  45. }
  46. &:active {
  47. background-color: darken($cor, $pre);
  48. }
  49. }
  50. /* 点击有内阴影 */
  51. @mixin btn-shadow($bgc: #4790d0,$pre: 5%) {
  52. background-color: $bgc;
  53. &:hover {
  54. background-color: darken($bgc,$pre);
  55. }
  56. &:active {
  57. -webkit-box-shadow: 0 3px 5px 0 rgba(0,0,0,.125) inset;
  58. -moz-box-shadow: 0 3px 5px 0 rgba(0,0,0,.125) inset;
  59. box-shadow: 0 3px 5px 0 rgba(0,0,0,.125) inset;
  60. }
  61. }
  62. /* 鼠标抬起出现点击后阴影 start*/
  63. @mixin spread($bgc: #4790d0, $point: .6, $spr: 5px) {
  64. position: relative;
  65. &:after {
  66. position: absolute;
  67. top: 0;
  68. left: 0;
  69. opacity: 0;
  70. content: "";
  71. @include box-shadow(0,0,0,$spr,rgba($bgc,$point));
  72. @include transition(all,.5s);
  73. }
  74. &:active:after {
  75. opacity: 1;
  76. @include box-shadow(0,0,0,0px,rgba($bgc,$point));
  77. @include transition(all,0s);
  78. }
  79. }
  80. /* 鼠标抬起出现点击后阴影 end */
  81. /* 波纹效果 start*/
  82. @mixin ripple($top: -10%, $left: 10%) {
  83. position: relative;
  84. overflow: hidden;
  85. &:after {
  86. position: absolute;
  87. display: block;
  88. opacity: 0;
  89. padding-top: 240%;
  90. padding-left: 240%;
  91. border-radius: 50%;
  92. margin-top: -120%;
  93. margin-left: -120%;
  94. background: rgba(255, 255, 255, .3);
  95. content: "";
  96. @include transition(all,1s);
  97. }
  98. &:active:after {
  99. opacity: 1;
  100. padding-top: 0;
  101. padding-left: 0;
  102. margin-top: $top;
  103. margin-left: $left;
  104. @include transition(all,0s);
  105. }
  106. }
  107. /* 波纹效果 end*/
  108. /* 不可点击 start*/
  109. @mixin disabled($fc: #999, $brc: #ccc, $bgc: #ddd) {
  110. border: 1px solid $brc;
  111. color: $fc;
  112. background: $bgc;
  113. cursor: no-drop;
  114. }
  115. /* 不可点击 end*/