我有一个很难解释的话把我找的,所以这里有一个例子:如何将div/snap/fit div封装成网格布局,TETRIS样式?
<div style="width:800px ">
<div style="width:200px;height:500px; background:purple; float:left"></div>
<div style="width:200px;height:200px; background:blue; float:left"></div>
<div style="width:200px;height:200px; background:green; float:left"></div>
<div style="width:200px;height:400px; background:yellow; float:right"></div>
<div style="width:400px;height:200px; background:orange; float:left"></div>
<div style="width:200px;height:200px; background:brown; float:left"></div>
<div style="width:400px;height:200px; background:gray; float:left"></div>
<div style="width:200px;height:100px; background:red; float:left;"></div>
</div>
这种布局与CSS结合左右彩车完成。我阅读了有关flexbox的信息,看看它是否可以实现,但看起来这是一个负面因素。
我意识到它可以通过将div嵌套到更大的div中来完成,但是我需要做出响应,并且此解决方案会使响应成为一场噩梦。
我一直试图远离jQuery和更深层次的编程,但我知道它可能是最好的选择。我很感谢这个社区的帮助;先谢谢你。
有相当多的库会为你做到这一点,一个例子是http://masonry.desandro.com/,它需要jQuery的。其他选项:http://designshack.net/articles/css/masonry/ – scrappedcola 2014-09-26 19:52:18
当你说,“俄罗斯方块风格”,你是否也想在你的布局中的L形块?或只是4面形状? – kevin628 2014-09-26 19:52:19
@scrappedcola谢谢。他们似乎能够解决我的问题,只要有些项目可以有2行/列宽(似乎他们可以)。 – 2014-09-29 12:04:19