【问题标题】:IE Preload Images Bug?IE 预加载图像错误?
【发布时间】:2010-08-14 15:02:26
【问题描述】:

好的,我正在为我的图像滑块调用精灵中的图像。发生的情况是,当页面加载时,所有幻灯片图像都水平显示,从而使其出现错误。我们制定的一个解决方案是将图像设置为预加载。它在 Firefox 中运行良好,但在 IE 中似乎有问题。以下是重要的两行代码(由于 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 文件的末尾:

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

我的 CSS 文件末尾有以下代码:

.slideshowload{display:none;}

有什么建议可以让它在 IE 中运行?

谢谢!

【问题讨论】:

    标签: image internet-explorer preloading


    【解决方案1】:

    一些事情:

    • 如果 !IE 用于非 IE 浏览器是多余的,因为只有 IE 理解条件 cmets,而您实际上是在使用不必要的不​​同语法重复相同的操作两次;
    • 您需要更正 IE 特定图像 - width="900px" 不是有效属性(应为 width="900",无单位);
    • 无论浏览器如何,始终指定图像的宽度/高度是一种很好的做法 - 在预加载的情况下,由于图像的 HTML 尺寸,在预加载阶段使用 width="1" height="1" 是可以接受的不影响下载本身

    【讨论】:

      猜你喜欢
      • 2011-06-26
      • 2014-06-23
      • 1970-01-01
      • 2012-10-11
      • 2018-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多