1

我正在尝试为我正在制作的这个模型导航栏上的这个按钮设置一个过渡,当我将鼠标悬停在上面时,我想要一个 0.5 秒的过渡来改变背景,但它不起作用我还没有真正使用过在 css 中转换很多,但这是伟大的谷歌告诉我的:

.btn-primary {
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 6px;
    background: -webkit-linear-gradient(bottom, #0066FF 0, #0088FF 85%, #00AAFF 100% );
    font-size: 14px;
    color: white;
}

.btn-primary:hover {
    background: -webkit-linear-gradient(bottom, #0000CC 0, #0044CC 100%);
    cursor: pointer;
    -webkit-transition: background 0.3s linear;
}

演示:http ://codepen.io/anon/pen/lApnj

任何信息都会非常感谢!:)

4

2 回答 2

1

不支持 CSS3 渐变过渡。。但是,您可以尝试这样的事情:

按钮

<a class="btn_primary" href="#">A button</a>

CSS

.btn_primary {
    background-color : #6BFF8A;
    background-image : linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.2) 100%);
    color : #fff;
    display : block;
    font-family : arial,sans-serif;
    font-size : 12px;
    padding : 5px 10px;
    text-align : center;
    text-decoration : none;
    transition : background-color 0.5s ease 0s;
    width : 75px;
}
.btn_primary:hover {
    background-color : #900;
}

这是我为你创造的一个小小提琴。

于 2013-04-26T20:04:43.210 回答
0

您必须像这样将转换置于类的正常状态:

.btn-primary {
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 6px;
    background: -webkit-linear-gradient(bottom, #0066FF 0, #0088FF 85%, #00AAFF 100% );
    font-size: 14px;
    color: white;
    -webkit-transition: background 0.3s linear;
}

.btn-primary:hover {
    background: -webkit-linear-gradient(bottom, #0000CC 0, #0044CC 100%);
    cursor: pointer;

}

编辑:这实际上是错误的,因为正如Kacey所说,不支持渐变过渡。对错误感到抱歉

于 2013-04-26T20:00:26.117 回答