这就是我到目前为止所得到的: http://jsfiddle.net/cHKF4/3/
但是我想把小盒子(盒子1和盒子2放在里面)
#late {
position: relative;
border-style: solid;
border-width: 3px;
border-color: #00fff3;
height: 200px;
width: 960px;
margin: 0 auto;
margin-top: 30px;
}
#box1 {
position: relative;
border-style: solid;
border-width: 1px;
border-color: #55fff3;
height: 100%;
width: 200px;
margin: 0 auto;
}
#box2 {
position: relative;
border-style: solid;
border-width: 3px;
border-color: #55fff3;
height: 100%;
width: 200px;
}
谢谢。
答案 0 :(得分:2)
Is this what you're trying to achieve(box1
和box2
并排在late
内,late
位于页面的中心位置):
<div id="late">
<div id="inner">
<div id="box1"></div>
<div id="box2"></div>
</div>
</div>
#late {
border: solid 3px #00fff3;
height: 200px;
width: 960px;
margin: 30px auto 0 auto;
}
#inner {
width: 408px;
height: 100%;
margin: 0 auto 0 auto;
}
#box1 {
border: solid 1px #55fff3;
height: 100%;
width: 200px;
float: left;
}
#box2 {
border: solid 3px #55fff3;
height: 100%;
width: 200px;
float: left;
}
答案 1 :(得分:1)
我不太明白你想要实现的目标。你想把#box1和#box2集中在#late吗?
如果您只是想将它们并排放在#late中,我就会这样做:http://codepen.io/AntonNiklasson/pen/rIdcj
答案 2 :(得分:1)
将float:left
添加到#box1
和#box2
#box1 {
float:left;
position: relative;
border-style: solid;
border-width: 3px;
border-color: #55fff3;
height: 100%;
width: 200px;
}
#box2 {
float:left;
position: relative;
border-style: solid;
border-width: 3px;
border-color: #55fff3;
height: 100%;
width: 200px;
}
答案 3 :(得分:1)
尝试
#box1 {
position: absolute;
top: 10px;
left: 10px;
}
将父容器的位置设置为相对。