我正在尝试使用CSS创建不规则的网格布局.到目前为止,这是我的Jfiddle:
码:
HTML:
<div style="width:275px;">
<div class="box" id="box1"></div>
<div class="box" id="box2"></div>
<div class="box" id="box4"></div>
<div class="box" id="box5"></div>
<div class="box" id="box3"></div>
<div class="box" id="box6"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.box { margin: 2px; float:left; }
#box1 { height: 86px; width: 80px; background-color: red;}
#box2 { height: 42px; width: 161px; background-color: green;}
#box3 { height: 42px; width: 80px; background-color: blue;}
#box4 { height: 86px; width: 80px; background-color: orange;}
#box5 { height: 129px; width: 80px; background-color: yellow;}
#box6 { height: 42px; width: 161px; background-color: brown;}
Run Code Online (Sandbox Code Playgroud)
我要做的是将蓝色块向上移动(直接在红色块下面),这将允许棕色块向左和向上移动.下面是目前看起来与我正在尝试做的事情的图像.

希望这是足够的信息,我很乐意澄清您是否需要更多信息.我知道像素略有偏差,它大约是我正在寻找的四分之一大小所以我将所有像素定义除以4,这导致了一些我忽略的小数(并导致线条)不完美匹配).
“肮脏”的解决方案,利润为负,但是......
.box { margin: 2px; float:left; }
#box1 { height: 86px; width: 80px; background-color: red;}
#box2 { height: 42px; width: 161px; background-color: green;}
#box3 { height: 42px; width: 80px; background-color: blue;margin-top:-87px;}
#box4 { height: 86px; width: 80px; background-color: orange;}
#box5 { height: 129px; width: 80px; background-color: yellow;}
#box6 { height: 40px; width: 163px; background-color: brown;margin-top:-42px;}
Run Code Online (Sandbox Code Playgroud)