我想创建一个这样的布局:
我正在寻找一个仅限CSS的解决方案。
答案 0 :(得分:5)
http://fiddle.jshell.net/2bSaP/show/
HTML:
<div id="container">
<div id="yellow"></div>
<div id="blue"></div>
<div id="green"></div>
<div id="red"></div>
</div>
CSS:
body {
margin: 0;
}
#yellow {
background: yellow;
position: absolute;
width: 150px;
top: 0;
left: 0;
bottom: 155px;
}
#blue {
background: rgb(98, 196, 255);
position: absolute;
top: 0;
right: 155px;
left: 155px;
bottom: 155px;
}
#green {
background: green;
position: absolute;
width: 150px;
top: 0;
right: 0;
bottom: 155px;
}
#red {
background: brown;
position: absolute;
height: 150px;
left: 0;
right: 0;
bottom: 0;
}
答案 1 :(得分:0)
用于
现在你忘了在你的css中position
定义position value
就像这样
#blue{
position: absolute;
}
答案 2 :(得分:0)
不确定这是否是您想要的,但我摆脱了#Blue
的所有身高规则,只是添加了height: 100%
,然后#Red
更高z-index
(例如55)。
现在中心方块似乎总是蓝色。
希望这有帮助
答案 3 :(得分:0)
我真的不确定你要完成什么。它应该看起来像MusikAnimal的jsfiddle的样子吗?
如果是这样,我会采用不同的结构(完整的正确高度和宽度......):
<div id="for3columns" style="height: 500px;">
<div id="yellow_column" style="float: left; width: 20%; height: 100%"></div>
<div id="blue_column" style="float: left; width: 60%; height: 100%"></div>
<div id="green_column" style="float: left; width: 20%; height: 100%"></div>
</div>
<div id="lower_red" style="clear:both; width: 100%; height: 100px;"></div>
答案 4 :(得分:0)
理解你的问题有点困难,但从我收集的内容来看,我能够找到这个解决方案:Fiddle
<div class='container'>
<div class='col col-left'></div>
<div class='col col-mid'></div>
<div class='col col-right'></div>
<div class='col col-bottom'></div>
</div>
.container {
width: 960px;
margin: 0 auto;
}
.col {
margin: 0;
padding: 0;
float: left;
}
.col-left {
width: 25%;
height: 200px;
background: #f90a7b;
}
.col-mid {
width: 50%;
height: 200px;
background: #e3f606;
}
.col-right {
width: 25%;
height: 200px;
background: #46c704;
}
.col-bottom {
width: 100%;
height: 200px;
background: #0654e0;
}