2013-08-03 31 views
0

我想在引导中设置样式和颜色按钮,但是当我更改颜色时,当它悬停时,它会出现像这样: **编辑:我需要更多信誉点来发布图像,但是什么当我将鼠标悬停在它上面时,只会显示所选颜色的一半。我认为这与bootstrap无法读取“渐变”有关。引导按钮着色问题

这是怎么回事?这里是我的代码:

.btn { 
    display: inline-block; 
    *display: inline; 
    padding: 4px 12px; 
    margin-bottom: 0; 
    *margin-left: .3em; 
    font-size: 14px; 
    line-height: 20px; 
    text-align: center; 
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); 
    vertical-align: middle; 
    cursor: pointer; 
    background-color: #ff0001; 
    *background-color: red; 
    background-image: -moz-linear-gradient(top, red, #e6e6e6); 
    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ff0001), to(#ff0001)); 
    background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6); 
    background-image: -o-linear-gradient(top, #ffffff, #e6e6e6); 
    background-image: linear-gradient(to bottom, #ffffff, #e6e6e6); 
    background-repeat: repeat-x; 
    border: 1px solid #cccccc; 
    *border: 0; 
    border-color: #e6e6e6 #e6e6e6 #bfbfbf; 
    border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); 
    border-bottom-color: #b3b3b3; 
    -webkit-border-radius: 4px; 
    -moz-border-radius: 4px; 
      border-radius: 4px; 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='red', endColorstr='red', GradientType=0); 
    filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); 
    *zoom: 1; 
    -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 
    -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 
} 
+0

什么是BTN悬停CSS?渐变显示正确:http://jsfiddle.net/j7EJX/没有悬停状态。这是什么浏览器的问题? – keeg

+0

您需要覆盖悬停状态的背景颜色,通常您应该使用渐变的底部颜色 –

回答

0

引导的按键应用了背景位置:

.btn:hover { 
background-position: 0 -15px; 
-webkit-transition: background-position 0.1s linear; 
-moz-transition: background-position 0.1s linear; 
-o-transition: background-position 0.1s linear; 
transition: background-position 0.1s linear; 
} 

您可以删除引导的主css文件的样式。或者这添加到您自己的css文件:

.btn:hover { 
background-position: 0px; 
}