【发布时间】:2015-07-11 14:21:06
【问题描述】:
我试图在鼠标悬停时更改我的背景图像,图像正在更改,但过渡正在闪烁,并且淡入/淡出似乎不起作用……
代码:
css:
.background {
position: fixed;
top:100px;
width: 100%;
height: 100%;
background: url(../img/angst.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
js:
$( ".project_link_01" )
.mouseover(function() {
$('.background').css('backgroundImage','url(../img/test.png)').fadeIn();
})
.mouseout(function() {
$('.background').css('backgroundImage','url(../img/angst.png)');
});
【问题讨论】:
-
当鼠标悬停时,当您拉起图像时,可能会因为加载图像的延迟而发生闪烁。尝试预加载它们。
标签: jquery css mouseover mouseenter