DIV+CSS3 两个DIV 我想让第一个div居中 然后第二个div紧挨着第一个DIV的右侧 谢谢各位的回答~

还没有解决.... 请热情的神们 帮帮我〜

div层是正行的就是最好不留空白
左右

<div style=" float:left; bored:1px solid #333; width:200px; "></div>
<div style=" float:left; bored:1px solid #F00; width:200px; "></div>
左中右
<div style=" float:left; bored:1px solid #00F; width:200px; "></div>
<div style=" float:left; bored:1px solid #333; width:200px; "></div>
<div style=" float:left; bored:1px solid #F00; width:200px; "></div>追问

#head{height: 113px; width: 876px; border: solid 1px red;margin: 0 auto;}
#head_right{height: 113px; width: 126px;border: solid 1px red;}

代码是这样的,我用margin: 0 auto;来居中了第一个div,可是我想把第二个div紧挨在第一个div上就不会了,~

追答

margin:0 auto是可以左右居中 但是他把左右的空间也给占了。
最好就是在一个层里有3个层。

追问

那我现在的情况下 要改的话 该怎么改呢?

追答

#head{height: 200px; width: 980px; border: solid 1px red;margin: 0 auto;}
#head_right{height: 198px; width: 300px;border-left: solid 1px red;}
#head_m{height: 198px; width: 377px;border-left: solid 1px red;}
#head_l{height: 198px; width: 300px;border-left: solid 1px red;}

我睡了 其余自己改吧

追问

嗯 我试试 谢谢~

来自:求助得到的回答
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-03-04
第一个div用margin:0 auto;来居中,第二个DIV用绝对定位来处理,这样就是紧紧的挨着了
第2个回答  2013-03-03
<div style="position:relative;width:100px;height:100px;background:red;margin:0 auto;">
第一个div
<div style="position:absolute;top:0;right:-100px;width:100px;height:100px;background:green;">
第二个div
</div>
</div>
第3个回答  2013-03-03
都绝对定位呗
相似回答