在一些网站上,我看到了这样的效果:如果我悬停一些菜单背景颜色不会立即改变,但它在某个特定的时间改变,它看起来像是动画,我如何才能获得这种效果?
发布于 2012-09-26 22:56:07
你想要研究的是CSS的过渡效果。Googled Results
看一下这个基本的jsFiddle,当你将鼠标悬停在上面时,背景颜色会褪色为红色。
CSS
div{
background-color: blue;
-webkit-transition: background-color 1000ms linear;
-moz-transition: background-color 1000ms linear;
-o-transition: background-color 1000ms linear;
-ms-transition: background-color 1000ms linear;
transition: background-color 1000ms linear;
}发布于 2012-09-26 22:55:16
这可以很容易地通过css3 transition (没有javascript)来完成,或者在旧浏览器的特定属性上制作动画
例如http://jsbin.com/ulayum/3/edit
a {
color: 000;
-webkit-transition: color 2s;
-msie-transition: color 2s;
-moz-transition: color 2s;
-o-transition: color 2s;
transition: color 2s;
}
a:hover {
color: #ccc;
}发布于 2012-09-26 22:53:34
这可能就是你要找的东西
$("div").hover(function () {
$(this).effect("highlight", {}, 3000);
});https://stackoverflow.com/questions/12604440
复制相似问题