所以我试图编写一个流体布局,并试验浮标。 第一步是开发一个简单的流体布局,其中有两个部分填充整个页面的宽度。蓝色框的宽度为25%,颜色为#0076a3。高度为600像素,绿色框的宽度为75%,颜色#7cc576。高度是600像素。然后我想在蓝色框内添加4个框,每个框的高度为150像素。如何安装外箱内的内箱?
之后,我想将这两个部分(由左分区和右分区形成)放在另一个宽度为1200px的中心。 我面临的问题是,只有我可以适当地将内盒(蓝色盒子和绿色盒子)放在外盒(灰色盒子)内。
#mainDiv {
width: 1200px;
margin: 0 auto;
background-color: #c2c2c2;
}
#leftDiv,
#rightDiv {
height: 600px;
margin: 0px;
}
#leftDiv {
width: 25%;
background-color: #0076a3;
float: left;
}
#rightDiv {
width: 75%;
background-color: #7cc576;
}
#box1,
#box2,
#box3,
#box4 {
height: 150px;
clear: both;
}
#box1 {
background-color: #6dcff6;
}
#box2 {
background-color: #00bff3;
}
#box3 {
background-color: #00aeef;
}
#box4 {
background-color: #0076a3;
}
<div id="mainDiv">
<div id="leftDiv">
<div id="box1"></div>
<div id="box2"></div>
<div id="box3"></div>
<div id="box4"></div>
</div>
<div id="rightDiv"></div>
</div>
这最后的输出应该是这样的:
这个问题需要进一步澄清 - 我不太确定你想达到的目标。你想把蓝色的盒子放在绿色的盒子里面吗? – rockmandew
我不确定“内部”和“外部”框是什么。请提供更多信息 – cocoa
@rockmandew不,我想把蓝色框和绿色框放在灰色框内 – abedzantout