我试图在鼠标悬停时使用jQuery为backgroundColor中的更改设置动画.
我已经检查了一些例子,我似乎做对了,它适用于其他属性,如fontSize,但我使用backgroundColor和"无效属性"js错误.我正在使用的元素是div.
$(".usercontent").mouseover(function() {
$(this).animate({ backgroundColor: "olive" }, "slow");
});
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我想知道是否有人知道webkit何时支持渐变的转换?
例如,以下代码在Chrome 6中不起作用(假设渐变过渡是一个链接):
.grad-transition {
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(white), to(black));
-webkit-transition: background-image .5s;
}
.grad-transition:hover {
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(black), to(white));
}
Run Code Online (Sandbox Code Playgroud) 是否真的没有办法用CSS动画渐变背景?
就像是:
@-webkit-keyframes pulse {
0% {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgb(196,222,242)), color-stop(0.5, rgb(242,242,242)), color-stop(1, rgb(240,240,240)));
}
50% {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgb(222,252,255)), color-stop(0.5, rgb(242,242,242)), color-stop(1, rgb(240,240,240)));
}
100% {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgb(196,222,242)), color-stop(0.5, rgb(242,242,242)), color-stop(1, rgb(240,240,240)));
}
}
Run Code Online (Sandbox Code Playgroud)
我知道,对于Safari 5.1+和Chrome 10+,有一个新的渐变语法,但是现在,我必须坚持使用旧的渐变语法.