1
我试图用动画构建照片组合的子导航。通常我会用CSS3转换来完成,但我需要一个适用于Internet Explorer 7-9的jQuery解决方案。背景图片闪烁jQuery .animate()
问题是背景图像在悬停时闪烁不定,我完全不知道为什么。在其他浏览器中FF一切看起来不错,只是所有IE都会造成问题。我读了很多,尝试了很多,但似乎没有什么让它变得更好。
你会明白我的意思,当你将鼠标悬停在下面的测试页http://www.webatweiss.de/test/test.html
的代码片段以下项目:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<head>
<title>gallery</title>
<script type="text/javascript" src="js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="js/jquery.backgroundPosition.js"></script>
<script>
$(document).ready(function(){
$("#subnav a").hover(
function() {$(this).stop().animate({"width":"96px", "height":"96px", "marginTop":"-48px", "marginLeft":"-48px", "backgroundPosition":"-2px -2px"}, 200);},
function() {$(this).stop().animate({"width":"86px", "height":"86px", "marginTop":"-43px", "marginLeft":"-43px", "backgroundPosition":"-7px -7px"}, 150);});
})
</script>
<STYLE type="text/css">
* {margin:0px;padding:0px;}
BODY{font:12px/100% arial;background:#a2a2a2;}
a {text-decoration:none;outline:none;border:none;}
ul {width:auto;float:left;list-style-type:none;}
ul#subnav {height:96px;position:relative;margin:50px;}
ul#subnav li {height:96px;width:96px;position:relative;float:left;margin-right:17px;}
ul#subnav li:last-child {margin-right:0px;}
a {width:86px;height:86px;position:absolute;border-radius:43px;top:50%;left:50%;margin:-43px 0px 0px -43px;background-position: -7px -7px;box-shadow: 0px 2px 3px #777;behavior:url(PIE.php);}
a:hover {width:96px;height:96px;border-radius:48px;top:50%;left:50%;position:absolute;margin:-48px 0px 0px -48px;background-position:-2px -2px;box-shadow: 0px 3px 4px #777;}
</style>
</HEAD>
<body>
<ul id="subnav" >
<li><a href="#" style="background-image:url(img/01.jpg);"></a></li>
<li><a href="#" style="background-image:url(img/02.jpg);"></a></li>
<li><a href="#" style="background-image:url(img/03.jpg);"></a></li>
<li><a href="#" style="background-image:url(img/04.jpg);"></a></li>
<li><a href="#" style="background-image:url(img/05.jpg);"></a></li>
</ul>
</body>
</html>