有些背景圖明明在 IE 下顯示正常,換到 Firefox、Chrome 卻怎麼都不出現,這其實是不同瀏覽器對 body 背景渲染方式的差異所致。本文示範如何修正。
body {
background:#F5F5F5 url(../images/a_55.jpg) no-repeat bottom left;
margin:0;
padding:0;
font-family:"微軟雅黑", "宋體", Arial, Verdana, sans-serif;
font-size:12px;
font-weight:normal;
color:#FFF;
text-align:left;
}
以上寫法只有 IE 能正常顯示背景圖,Firefox 與 Chrome 卻完全看不到。
把選擇器從 body 改成 html,body,讓背景同時套用到 html 與 body 上即可:
html,body {
background:#F5F5F5 url(../images/a_55.jpg) no-repeat bottom left;
margin:0;
padding:0;
font-family:"微軟雅黑", "宋體", Arial, Verdana, sans-serif;
font-size:12px;
font-weight:normal;
color:#FFF;
text-align:left;
}