jquery - 背景图像闪烁与 jQuery .animate()

标签 jquery css background jquery-animate flicker

我正在尝试为带有动画的照片组合构建子导航。通常我会使用 CSS3 转换来完成它,但我需要一个适用于 Internet Explorer 7-9 的 jQuery 解决方案。

问题是背景图像在悬停时以某种方式闪烁,我完全不知道为什么。在其他浏览器中,例如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>

最佳答案

我已经看过几次了。虽然它还没有实现绝对完美的过渡,但确实有所帮助。

将此添加到您正在滑动的图像上的 CSS。

opacity: 1;
filter: alpha(opacity=100);
zoom: 1;

关于jquery - 背景图像闪烁与 jQuery .animate(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8145781/

相关文章:

html div 背景图片不显示

android - TextView 的白色背景不透明度为 50%

javascript - 在 JS 数组上使用 jquery 数据表执行一些 css

javascript - 向下滚动时隐藏标题,向下滚动时显示

css - 使用 CSS 播放动画后更改图像位置或类?

html - 文本不显示在边框 html/css 上

javascript - 使用动态内容平滑 jScrollPane 滚动条长度调整

jquery - 主题标题中的自定义 jQuery 和 CSS

jquery - 使用 jquery 修改 .css 高度或宽度基于哪个更大

css - onClick CSS 背景更改