【发布时间】:2012-10-19 04:11:54
【问题描述】:
可能重复:
Centering one div while another div is floated to the right?
我正在尝试将 container1 居中并将 container2 浮动到它的右侧,以便它稍微离开页面:
示例:http://i.imgur.com/JHkfn.jpg
不幸的是,容器 2 在容器 1 的下方和右侧跳跃,正如您在站点模型中看到的那样(链接在下方。)
网站模型: http://ad313.samrandolphdesign.com/
CSS:
#container1 {
margin: auto;
background-color: #FFF;
width: 80%;
height: 100%;
max-width: 600px;
padding-bottom: 15px;
display: block;
}
#container2 {
background-color: #CC9900;
max-width: 600px;
width: 80%;
height: 100%;
padding-top: 60px;
padding-bottom: 50px;
text-align: center;
float: right;
display: block;
}
【问题讨论】: