【发布时间】:2013-04-01 22:45:24
【问题描述】:
此按钮的设计要求它具有线性渐变,但是当您将鼠标悬停在它上面时,该按钮应该变为纯色。主类看起来像这样,它似乎在我测试过的所有浏览器中都可以正常工作。如您所见,我也在使用 PIE 使渐变在较低的 IE 浏览器中正常工作。
.mvcView.button.texture {
background-color: #F34914;
border-width: 0px;
color: #fff;
cursor: pointer;
font-size: 14px;
font-weight: bold;
padding: 4px;
min-width: 40px;
overflow:visible; /*overflow visible is required for ie 7 to respect min-width and doesn't seem to affect other browsers. */
width : auto;
vertical-align: middle;
font-family: Arial;
background-color: #F34914;
background: -webkit-linear-gradient(top, #F34914, #8A2800);
background: -moz-linear-gradient(top, #F34914, #8A2800);
background: -ms-linear-gradient(top, #F34914, #8A2800);
background: -o-linear-gradient(top, #F34914, #8A2800);
background: linear-gradient(top, #F34914, #8A2800);
-pie-background: linear-gradient(#F34914, #8A2800);
behavior: url('/PIE.htc');
}
对于 webkit 浏览器,以下 css 将颜色更改为在鼠标悬停时变平:
.mvcView.button.texture:hover {
background: #AA3200;
}
对于 IE9,只有当我这样做时,悬停才有效:
.mvcView.button.texture:hover {
background: #AA3200;
background-color: #AA3200;
-pie-background: linear-gradient(#AA3200, #AA3200);
behavior: url('/PIE.htc');
}
还有其他更优雅的方法吗?
【问题讨论】:
标签: css internet-explorer-9 hover css3pie linear-gradients