4.21.1 btn按钮样式主题

在theme里,与btn相关的样式主要对按钮阴影和背景颜色进行了增强(或改变)。默认状态下的按钮的阴影调整代码如下:

  1. // 源码7行
  2. .btn-default,.btn-primary,
  3. .btn-success,.btn-info,
  4. .btn-warning,.btn-danger {
  5. text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);
  6. -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 1px rgba
  7. (0, 0, 0, 0.075);
  8. box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 1px rgba(0,
  9. 0, 0, 0.075);
  10. }

高亮状态下的按钮阴影调整代码如下:

  1. // 源码17行
  2. .btn-default:active,.btn-primary:active,
  3. .btn-success:active,.btn-info:active,
  4. .btn-warning:active,.btn-danger:active,
  5. .btn-default.active,.btn-primary.active,
  6. .btn-success.active,.btn-info.active,
  7. .btn-warning.active,.btn-danger.active {
  8. -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
  9. box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
  10. }
  11. .btn:active,.btn.active { background-image: none;}

另外,在新版本中针对按钮的每一种风格,对其相关的边框、背景图,以及不同状态下的背景色和边框颜色都进行了增强和改变。以.btn-default样式为例,其源码如下:

  1. // 源码36行
  2. .btn-default {
  3. text-shadow: 0 1px 0 #fff;
  4. background-image: -webkit-linear-gradient(top, #fff 0%, #e0e0e0 100%);
  5. background-image: linear-gradient(to bottom, #fff 0%, #e0e0e0 100%);
  6. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', end
  7. Colorstr='#ffe0e0e0', GradientType=0);
  8. filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
  9. background-repeat: repeat-x;
  10. border-color: #dbdbdb;
  11. border-color: #ccc;
  12. }
  13. .btn-default:hover,.btn-default:focus { background-color: #e0e0e0; background-
  14. position: 0 -15px;}
  15. .btn-default:active,.btn-default.active { background-color: #e0e0e0; border-color:
  16. #dbdbdb;}