_button.scss 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. @charset "utf-8";
  2. /*
  3. * @file: 按钮基础UI组件
  4. * @update: 2015-06-07 17:57:18
  5. */
  6. /*
  7. * 默认按钮
  8. * @base
  9. * @param: button-variant(字体颜色, 背景色, 边框颜色)
  10. * @param: button-size($padding-vertical, $padding-horizontal, $font-size, $border-radius)
  11. */
  12. /* 按钮大小配置 */
  13. $btn-height: 30px !default; // 按钮高度
  14. $btn-padding-horizontal: 18px !default; // 按钮padding left/right值
  15. $btn-font-size: 12px !default; // 按钮字号大小
  16. $btn-radius: 2px !default; // 按钮圆角值
  17. /* 默认按钮配色 */
  18. $btn-color: #288ad6 !default; // 字体颜色
  19. $btn-bg: #fff !default; // 背景色
  20. $btn-border: #288ad6 !default; // 边框颜色
  21. /* 禁用按钮配置 */
  22. $disabled-btn-color: #999 !default; // 字体颜色
  23. $disabled-btn-bg: #f5f5f5 !default; // 背景色
  24. $disabled-btn-border: #e6e6e6 !default; // 边框颜色
  25. .ui-btn {
  26. @include inline-block;
  27. @include button-size(($btn-height - $btn-font-size)/2 - 1, $btn-padding-horizontal, $btn-font-size, $btn-radius);
  28. @include button-variant($btn-color, $btn-bg, $btn-border);
  29. width: auto; // 宽度自适应
  30. line-height: 1; // 重置某些浏览器内置的私有属性默认定义的行高
  31. border: 1px solid; // 某些浏览器私有属性里面额外设置了border
  32. cursor: pointer;
  33. text-align: center;
  34. vertical-align: middle;
  35. *overflow: visible; // fix IE6/IE67 button随着字变宽
  36. user-select: none;
  37. transition: all .2s ease-in-out;
  38. /*
  39. * 激活状态
  40. * @state: active
  41. */
  42. &.is-active,
  43. &:active {
  44. outline: 0; // 隐藏点击时的outline
  45. box-shadow: inset 0 3px 5px rgba(0, 0, 0, .08);
  46. }
  47. /*
  48. * 禁用状态
  49. * @state: disabled
  50. */
  51. &.is-disabled,
  52. &[disabled] {
  53. color: $disabled-btn-color;
  54. background-color: $disabled-btn-bg;
  55. border-color: $disabled-btn-border;
  56. &.is-hover,
  57. &:hover {
  58. cursor: not-allowed;
  59. color: $disabled-btn-color;
  60. background-color: $disabled-btn-bg;
  61. border-color: $disabled-btn-border;
  62. }
  63. &.is-active,
  64. &:active {
  65. box-shadow: none;
  66. }
  67. }
  68. }
  69. a.ui-btn {
  70. text-decoration: none;
  71. &:hover {
  72. text-decoration: none;
  73. }
  74. }
  75. input.ui-btn,
  76. button.ui-btn {
  77. *padding: ($btn-height - $btn-font-size)/2 - 2 $btn-padding-horizontal - 1 ($btn-height - $btn-font-size)/2 - 3; // IE6/IE67在垂直方向会高出3px,水平方向多出2px
  78. }
  79. /*
  80. * 首选按钮
  81. * @extend: primary
  82. * @param: button-variant(字体颜色, 背景色, 边框颜色)
  83. */
  84. .ui-btn {
  85. &.ext-primary {
  86. @include button-variant($primary-text-color, $primary-color, $primary-color);
  87. }
  88. }
  89. /*
  90. * 成功按钮
  91. * @extend: success
  92. * @param: button-variant(字体颜色, 背景色, 边框颜色)
  93. */
  94. .ui-btn {
  95. &.ext-success {
  96. @include button-variant($success-text-color, $success-color, $success-color);
  97. }
  98. }
  99. /*
  100. * 信息按钮
  101. * @extend: info
  102. * @param: button-variant(字体颜色, 背景色, 边框颜色)
  103. */
  104. .ui-btn {
  105. &.ext-info {
  106. @include button-variant($info-text-color, $info-color, $info-color);
  107. }
  108. }
  109. /*
  110. * 警告按钮
  111. * @extend: warning
  112. * @param: button-variant(字体颜色, 背景色, 边框颜色)
  113. */
  114. .ui-btn {
  115. &.ext-warning {
  116. @include button-variant($warning-text-color, $warning-color, $warning-color);
  117. }
  118. }
  119. /*
  120. * 危险按钮
  121. * @extend: danger
  122. * @param: button-variant(字体颜色, 背景色, 边框颜色)
  123. */
  124. .ui-btn {
  125. &.ext-danger {
  126. @include button-variant($danger-text-color, $danger-color, $danger-color);
  127. }
  128. }
  129. /*
  130. * 块状按钮
  131. * @extend: block
  132. */
  133. .ui-btn {
  134. &.ext-block {
  135. display: block;
  136. text-align: center;
  137. }
  138. }