+ -
当前位置:首页 → 问答吧 → body背景,ie6下水平居中并不居中

body背景,ie6下水平居中并不居中

时间:2011-04-19

来源:互联网

代码里,div的宽度跟body背景的宽度具有相同的值,且都水平居中。
在ie6下运行,body背景的右边缘漏出了1个像素(图1),而没有重合。(其他浏览器重合图2)
为什么会这样?怎么解决哦?
2.JPG (3.44 KB)
图2
2011-4-19 13:43
图1
1.JPG (3.38 KB)
图1
2011-4-19 13:43
图2
<!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> *{ margin:0; padding:0 } body{ background:url(http://216.vipshop.com/upload/brand/201104/2011041909381573601.jpg) center top no-repeat } div{ width:590px; height:100px; margin:50px auto; background:red } </style> </head> <body> <div></div> </body> </html>
 提示:您可以先修改部分代码再运行
[ 本帖最后由 twming 于 2011-4-19 13:45 编辑 ]

作者: twming   发布时间: 2011-04-19

本来就应该是遮不住的
你写了 margin:50px auto;
背景透明  body的背景自然能被看见
可以
复制内容到剪贴板
代码:
div{margin:0 auto; 或 margin:0 auto;padding:50px 0;}
抱歉 刚才看的时候 没有图 没理解你的意思

[ 本帖最后由 businessDiv 于 2011-4-19 14:21 编辑 ]

作者: businessDiv   发布时间: 2011-04-19

热门下载

更多