2010-08-14 95 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尺寸不影響下載本身