2013-04-29 63 views
0

我在這裏以下尖端脫穎而出調整圖像大小在IE8:http://blog.kurtschindler.net/post/flexible-dynamically-resizing-images-with-css圖片在IE8不調整時瀏覽器的寬度變化

我有沒有運氣得到這個在我的網站工作,雖然。我在這裏寫了一些簡單的代碼來消除任何複雜性,但我仍然沒有找到任何地方。我必須錯過簡單的東西。

<html> 
    <head> 
    <style> 
    .container img { 
    max-width: 100%; 
    height: auto; 
    width: auto; /*for ie8*/ 
    } 
    .container { 
    width: 100%; 
    } 
    </style> 
    </head> 
    <body> 
    <div class="container"> 
    <img src="image.jpg" /> 
    </div> 
    </body> 
</html> 
+1

請確保你有一個文檔類型:'<!doctype html>'應該足以進行測試 – lnrbob 2013-04-29 21:41:59

+0

這樣做得到了上面的示例工作。謝謝。 – StevieD 2013-04-30 00:46:44

+0

不用擔心,很高興它幫助:) – lnrbob 2013-04-30 09:29:37

回答

2

這是您可能需要的只是CSS:

.container img { 
    width: 100%; 
} 
.container { 
    width: 100%; 
} 

圖像將與瀏覽器擴展。

+0

這讓我在修復我的網站的正確軌道上。謝謝。 – StevieD 2013-04-30 00:46:23

相關問題