我正在尝试使用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>
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;}
我想要做的是将蓝色块向上移动(直接放在红色块下面),这样棕色块就可以向左上移动。下面是当前的样子和我想要的样子的对比图。
希望这些信息足够了解问题,如果需要更多信息我很乐意进行澄清。我知道像素有点不准确,它只有我所需大小的四分之一大小,因此我将所有像素定义除以4,这导致一些小数被忽略(并导致线条不能完美匹配)。