您的位置:首页 > 其它

div容器中内嵌2个 div,如何让容器div在页面中居中

2010-05-05 11:14 267 查看
left和right div必须在layout中居中显示,同时layout必须在页面中居中显示。样式该如何写?

------------------------------------------ 以下写法不对。(浏览器为IE7) -----------------------------------------

回答一: #layout{margin-left:auto;margin-right:auto;width:76%;} 或者 #layout{margin:auto;}

回答二: #layout{margin:auto;width:408px; } #left { width:200px; height:300px; float:left; } #right { width:200px; height:300px; float:right; }

回答三: margin-right:auto; margin-left:auto; 父容器text- align:center;

回答四:把三个DIV的position都设成absolute,绝对样式下设置三个层的left和top属性,慢慢调吧.肯定灵.

回答五: #layout { margin:0px auto; width:408px; padding-top: 25px; padding-bottom: 25px; /×text-align:center;*/ } 不要给layout设置高度就OK了!~~ IE6.0 IE7.0都是好的!~~ 补充提问一下:这种方法FF不支持,但是网上有种方法说可以解决,就是加一个空层,清除浮动,但是我试了在 FF下也是行不通的,

回答五:呵,在我的不懈努力下,FF下自适应高度问题被我解决了在layout中加入 height:auto!important; height:200px; min-height:200px; 就 OK了!~~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: