Special 'Float' in Mosaic of Boxes

我与影子孤独终老i 提交于 2020-01-03 04:34:14

问题


I'm working with a mosaic (jsFiddle) made with simple CSS and HTML.

The mosaic has rows and columns of the same width and height. Each one of its cells should be filled by an entire box or a part of it. In other words, every box should occupy one or more boxes length-wise and one or more boxes width-wise.

When all the boxes take up only one row, everything works fine. However, when I try to make a box bigger than a row, the float:left stops working the way I want it to:

http://img198.imageshack.us/img198/5207/boxshoudgohere.png

jsFiddle with the issue as displayed above.

As illustrated above, the gray boxes that are (in the HTML) right next to the big box skip to the next row; I need to move the boxes to where the red arrows point. My question is: how can I prevent the gray boxes from moving?

Take into account that I would prefer a clean solution. In other words, moving the boxes with absolute or relative positioning wouldn't be the best option since the boxes and their width/height are generated by JavaScript (although feel free to post any answer).

Thanks for your time.


回答1:


Jquery Masonry will do this for you. Unfortunately you won't achieve what you're after with simple markup and CSS.




回答2:


You can't do that using a clean CSS code.

But you can use javascript, there are some jQuery plugins which do that, you could try Isotope



来源:https://stackoverflow.com/questions/12327281/special-float-in-mosaic-of-boxes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!