IE8下div+CSS

來源:互聯網
上載者:User

一種在用戶端解決
其實解決方案很簡單。用IE8瀏覽器開啟你的網站,如果發現錯位問題,請不用驚慌。在功能表列上,開啟“工具”選項,在下拉式功能表裡找到“相容性檢視”,勾選上,你再看,是不是網站沒再錯位了。
二網站本身解決
IE8對margin:0 auto;這個CSS好像不再有用了,頁面不能置中啦,下午回來再看看有什麼辦法置中,太平洋的前端也說他們公司無視IE8的存在,測試還是以前的版本。
原因找到啦,我把margin:0 auto;寫在了body標籤中,IE7以下都可以置中,IE8就不行,解決辦法是,把這代碼寫在div大架構中就可以了。
百度搜尋的資料:
程式碼
<style type="text/css">
body{text-align:center;width:100%;}
#wrap{
text-align:left;
width:560px;
margin:0 auto;
border:1px solid #333;
background-color:#ccc;
}
</style>
<div id="wrap"> 在所有瀏覽器中都有效方法: <pre> 在所有瀏覽器中都有效方法: 在所有瀏覽器中都有效方法: 在所有瀏覽器中都有效方法:
</pre>
</div>

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.