2012-12-23 46 views
0

我創建了一個圖像庫,在使用FF 17.0.1,Chrome 23.0.1271.97或Safari 5.0.3進行監視時看起來不錯。工具「IETester」也爲IE 9正確顯示頁面。當在IE8中以兼容模式查看時,它也呈現良好,但不是默認模式。CSS屬性'max-width'使Internet Explorer 8中的圖像崩潰

CSS文件「core.css」,增加了以下規則:

/* Image ---*/ 
img { 
    max-width: 100%; 
} 

我不知道,如果它是如此多的第三方模板之一,我可以改變這個規則。 這條規則似乎崩潰了我的IE8的畫廊的圖像。設置附加規則'寬度:自動'不是一個選項,因爲圖像並不總是以原始大小顯示。

HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" dir="ltr" > 

    <head> 
     <title></title> 
    <link rel="stylesheet" href="/media/plg_fancybox2/css/aobgallery.css" type="text/css" /> 
    <link rel="stylesheet" type="text/css" href="/templates/ja_lens/css/reset.css" media="all" /> 
    <link rel="stylesheet" type="text/css" href="/templates/ja_lens/css/core.css" media="all" /> 

    </head> 
    <body> 


    <p><script type='text/javascript'>var tlist = ['/images/showroom/playground/displaced/Disp_7b1.jpg','/images/showroom/playground/displaced/dispm_6.jpg','/images/showroom/playground/displaced/dispm_9.jpg','/images/showroom/playground/displaced/dispm_9b.jpg','/images/showroom/playground/displaced/dispm_9c.jpg','/images/showroom/playground/displaced/dispm_10a.jpg','/images/showroom/playground/displaced/dispm_12b.jpg','/images/showroom/playground/displaced/dispm_12d.jpg','/images/showroom/playground/displaced/dispm_12e.jpg','/images/showroom/playground/displaced/dispm_12f.jpg']; 

    </script><div id="fancycontainer"> 
    <div class="fancyitem"><a href="/images/showroom/playground/displaced/Disp_7b1.jpg" class="fancyframe" rel="gallery" onclick="callMe(tlist,{index: 0,helpers : { title : { type : 'inside' }, buttons : {}}, playSpeed: 5000, closeBtn : false});return false;"><img width="215" src="/images/showroom/playground/displaced/thumbs/Disp_7b1.jpg" /></a></div> 

    <div class="fancyitem"><a href="/images/showroom/playground/displaced/dispm_6.jpg" class="fancyframe" rel="gallery" onclick="callMe(tlist,{index: 1,helpers : { title : { type : 'inside' }, buttons : {}}, playSpeed: 5000, closeBtn : false});return false;"><img width="215" src="/images/showroom/playground/displaced/thumbs/dispm_6.jpg" /></a></div> 

    <div class="fancyitem"><a href="/images/showroom/playground/displaced/dispm_9.jpg" class="fancyframe" rel="gallery" onclick="callMe(tlist,{index: 2,helpers : { title : { type : 'inside' }, buttons : {}}, playSpeed: 5000, closeBtn : false});return false;"><img width="215" src="/images/showroom/playground/displaced/thumbs/dispm_9.jpg" /></a></div> 

    <div class="fancyitem"><a href="/images/showroom/playground/displaced/dispm_9b.jpg" class="fancyframe" rel="gallery" onclick="callMe(tlist,{index: 3,helpers : { title : { type : 'inside' }, buttons : {}}, playSpeed: 5000, closeBtn : false});return false;"><img width="215" src="/images/showroom/playground/displaced/thumbs/dispm_9b.jpg" /></a></div> 

    <div class="fancyitem"><a href="/images/showroom/playground/displaced/dispm_9c.jpg" class="fancyframe" rel="gallery" onclick="callMe(tlist,{index: 4,helpers : { title : { type : 'inside' }, buttons : {}}, playSpeed: 5000, closeBtn : false});return false;"><img width="215" src="/images/showroom/playground/displaced/thumbs/dispm_9c.jpg" /></a></div> 

    <div class="fancyitem"><a href="/images/showroom/playground/displaced/dispm_10a.jpg" class="fancyframe" rel="gallery" onclick="callMe(tlist,{index: 5,helpers : { title : { type : 'inside' }, buttons : {}}, playSpeed: 5000, closeBtn : false});return false;"><img width="215" src="/images/showroom/playground/displaced/thumbs/dispm_10a.jpg" /></a></div> 

    <div class="fancyitem"><a href="/images/showroom/playground/displaced/dispm_12b.jpg" class="fancyframe" rel="gallery" onclick="callMe(tlist,{index: 6,helpers : { title : { type : 'inside' }, buttons : {}}, playSpeed: 5000, closeBtn : false});return false;"><img width="215" src="/images/showroom/playground/displaced/thumbs/dispm_12b.jpg" /></a></div> 

    <div class="fancyitem"><a href="/images/showroom/playground/displaced/dispm_12d.jpg" class="fancyframe" rel="gallery" onclick="callMe(tlist,{index: 7,helpers : { title : { type : 'inside' }, buttons : {}}, playSpeed: 5000, closeBtn : false});return false;"><img width="215" src="/images/showroom/playground/displaced/thumbs/dispm_12d.jpg" /></a></div> 

    <div class="fancyitem"><a href="/images/showroom/playground/displaced/dispm_12e.jpg" class="fancyframe" rel="gallery" onclick="callMe(tlist,{index: 8,helpers : { title : { type : 'inside' }, buttons : {}}, playSpeed: 5000, closeBtn : false});return false;"><img width="215" src="/images/showroom/playground/displaced/thumbs/dispm_12e.jpg" /></a></div> 

    <div class="fancyitem"><a href="/images/showroom/playground/displaced/dispm_12f.jpg" class="fancyframe" rel="gallery" onclick="callMe(tlist,{index: 9,helpers : { title : { type : 'inside' }, buttons : {}}, playSpeed: 5000, closeBtn : false});return false;"><img width="215" src="/images/showroom/playground/displaced/thumbs/dispm_12f.jpg" /></a></div> 

    </div></p> 



    </body> 
    </html> 

這是用於格式化庫的CSS: aobgallery.css

#fancycontainer 
{ 
    list-style: none outside none; 
    margin: 8px auto !important; 
    overflow: hidden; 
    padding: 8px !important; 
    border:1px solid #000000; 
} 

.fancyframe 
{ 
    display: block; 
    float:left; 
    font-size: 11px; 
    font-weight: bold; 
    left: 0; 
    padding: 5px; 
    right: 0; 
    text-align: left; 
    top: 0; 
} 


.fancyframe:hover 
{ 
    background-color: #333333; 
} 

爲什麼了屬性 '最大寬度' 設置爲100%在IE8中摺疊圖像? 我可以修改我的html以防止這種情況發生嗎? 我可以定義一個額外的CSS規則嗎?

這是問題的一個在線演示: http://demo.artonbit.com/test.htm

回答

0

這是IE8的錯誤,其中,容器會收縮到圖像的寬度。我在路上,現在無法在我的錯誤列表中查看它,但如果沒有其他人提供完整說明,我相信您可以通過Google進行查詢。

解決的辦法可能是在圖像周圍設置一個div,並將最大寬度放在div上。這個問題是由img所代替的元素造成的。 (嗯,問題實際上是由IE導致的,但我離題了。)

+0

當我把一個div放在img標籤上,並且將div的寬度設置爲它所包含的圖像的寬度時,它似乎可以工作。 –

1

那麼你嘗試過重新編排CSS訂單?在我看來,你會想把這個'重新設置爲加載順序的前面,以幫助重置間距剔除瀏覽器。

這有助於解釋的CSS復位的點: What's the purpose of using CSS browser reset code?

+0

是的,那是我第一次猜測。不幸的是,這並不能解決問題。感謝有關重置的鏈接。我不久就完全移除了重置表,這樣可以得到更好的結果,但條紋仍然很小。 –

+0

你有沒有考慮在你的css風格中包含PIE.HTC?它通常解決了很多舊的IE樣式問題。 – jonc

+0

是的,我確實。但我無法讓它在joomla上運行。這是另一個問題,但總之,我認爲IE無法找到PIE.htc。我把它放在joomla的許多地方(主目錄,模板目錄...),但我從未看到有什麼事情發生。另外,這個「相對於html文件」閱讀位置的行爲是...糟糕。我不知道我是否真的可以使用PIE。 –