2010-08-14 102 views
0

好吧,所以我从图片滑块调用图片。会发生什么情况是,当页面加载时,所有幻灯片图像都会显示为水平状态,从而使其显示出错误。我们制定的解决方案是将图像设置为预加载。它在Firefox中正常工作,但在IE中它看起来很麻烦。下面是两行代码说事(我们已经把事情间隔由于IE中的另一个bug):IE预加载图片错误?

<div id="banner"><div class="slideshow"><!--[if IE]> 
    <img id="ban_images1" src="images/spacer.gif" width="900px" height="244" border="0"/> 
    <img id="ban_images2" src="images/spacer.gif" width="900px" height="244" border="0"/> 
    <img id="ban_images3" src="images/spacer.gif" width="900px" height="244" border="0"/> 
    <img id="ban_images4" src="images/spacer.gif" width="900px" height="244" border="0"/> 
    <img id="ban_images5" src="images/spacer.gif" width="900px" height="244" border="0"/> 
    <img id="ban_images6" src="images/spacer.gif" width="900px" height="244" border="0"/> 
    <img id="ban_images7" src="images/spacer.gif" width="900px" height="244" border="0"/> 
    <img id="ban_images8" src="images/spacer.gif" width="900px" height="244" border="0"/> 
    <img id="ban_images9" src="images/spacer.gif" width="900px" height="244" border="0"/> 
    <img id="ban_images10" src="images/spacer.gif" width="900px" height="244" border="0"/> 
<![endif]--> 
<![if !IE]> 
    <img id="ban_images1" /> 
    <img id="ban_images2" /> 
    <img id="ban_images3" /> 
    <img id="ban_images4" /> 
    <img id="ban_images5" /> 
    <img id="ban_images6" /> 
    <img id="ban_images7" /> 
    <img id="ban_images8" /> 
    <img id="ban_images9" /> 
    <img id="ban_images10" /> 
<![endif]> 
    </div> 

潘基图片只是指的是位于main.gif精灵。

要做到预加载,我把下面的代码在我的HTML文件的末尾:

.slideshowload{display:none;} 

任何建议到:

<div class="slideshowload"><img src="image/main.gif" /></div> 

而在我的CSS文件的末尾下面的代码让它在IE中工作?

谢谢!

回答

0

有几件事情:

  • 如果IE的非IE的浏览器是多余的,因为只有IE理解有条件的意见和你基本上与不必要的不​​同语法重复同样的动作两次!
  • 您需要更正您的特定于IE的图像 - width =“900px”不是有效的属性(应该是width =“900”,没有单位);
  • 不管浏览器如何总是指定图像的宽度/高度是一种很好的做法 - 在预加载的情况下,在预加载阶段使用width =“1”height =“1”是可以接受的,因为图像的HTML尺寸不影响下载本身