4.21.1 btn按钮样式主题
在theme里,与btn相关的样式主要对按钮阴影和背景颜色进行了增强(或改变)。默认状态下的按钮的阴影调整代码如下:
- // 源码7行
- .btn-default,.btn-primary,
- .btn-success,.btn-info,
- .btn-warning,.btn-danger {
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);
- -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 1px rgba
- (0, 0, 0, 0.075);
- box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 1px rgba(0,
- 0, 0, 0.075);
- }
高亮状态下的按钮阴影调整代码如下:
- // 源码17行
- .btn-default:active,.btn-primary:active,
- .btn-success:active,.btn-info:active,
- .btn-warning:active,.btn-danger:active,
- .btn-default.active,.btn-primary.active,
- .btn-success.active,.btn-info.active,
- .btn-warning.active,.btn-danger.active {
- -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
- box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
- }
- .btn:active,.btn.active { background-image: none;}
另外,在新版本中针对按钮的每一种风格,对其相关的边框、背景图,以及不同状态下的背景色和边框颜色都进行了增强和改变。以.btn-default样式为例,其源码如下:
- // 源码36行
- .btn-default {
- text-shadow: 0 1px 0 #fff;
- background-image: -webkit-linear-gradient(top, #fff 0%, #e0e0e0 100%);
- background-image: linear-gradient(to bottom, #fff 0%, #e0e0e0 100%);
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', end
- Colorstr='#ffe0e0e0', GradientType=0);
- filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
- background-repeat: repeat-x;
- border-color: #dbdbdb;
- border-color: #ccc;
- }
- .btn-default:hover,.btn-default:focus { background-color: #e0e0e0; background-
- position: 0 -15px;}
- .btn-default:active,.btn-default.active { background-color: #e0e0e0; border-color:
- #dbdbdb;}