2011-10-26 81 views
4

我試圖限制圖像寬度只有CSS:的Internet Explorer 9 - 調整圖像比例

#lateral-derecho #patrocinadores img 
{ 
    max-width: 130px; 
    height: auto; 
    margin: 0 auto; 
} 

而且每一個瀏覽器是做什麼的,除了IE 9,它不這樣做是按比例沒事。我正在運行它在<meta http-equiv="X-UA-Compatible" content="IE=8" />

順便說一句,標準模式下的IE 9甚至不理解margin: 0 auto;或者我做錯了什麼?他們又做了一個蹩腳的瀏覽器?

編輯:這是所有的CSS,容器(#patrocinadores)和IMG,IMG包含內部#patrocinadores > a > img

#lateral-derecho #patrocinadores 
{ 
    float: right; 
    width: 136px; 
    margin-top: 25px; 
    padding: 15px 0 5px; 
    background: url(images/top-patrocinadores.png) top no-repeat #eee; 
    text-align: center; 
} 

#lateral-derecho #patrocinadores a{display: block;} 
#lateral-derecho #patrocinadores img 
{ 
    max-width: 130px; 
    height: auto; 
    margin: 0 auto; 
} 

回答

0

擺脫height: auto;的。你不需要它,這是問題的原因。

+0

不,實際上,如果我擺脫它,所有瀏覽器調整它不成比例,也IE9,所以我需要它的真正的瀏覽器工作。謝謝 –

+0

@ user761076不,那你在其他地方有一些不正確的CSS。如果你不告訴他們爲什麼其他瀏覽器會設置高度?不,你在這個圖像上設置一個高度,你不應該。使用螢火蟲找出並刪除它。 – Ariel

+0

@ user761076嗯 - 你是否在圖片標籤中加入了高度?如果你然後刪除它(以及寬度)。不要在標籤和CSS中設置尺寸,它會導致奇怪的問題。 – Ariel

1

試試這個:

#lateral-derecho #patrocinadores a { 
    display: block; 
    max-width: 130px; 
} 
#lateral-derecho #patrocinadores img { 
    max-width: 100%; 
} 

如果你想爲IE < 9良好的品質縮放,你要包括AlphaImageLoader並設置sizingMethodscale

+1

謝謝,但也不工作......你確定IE9不會在你的機器上這樣做嗎? IE8正常工作,但IE9不... –