CSS Block float left

前端 未结 3 1484
既然无缘
既然无缘 2021-01-28 04:28

I have this html file

    
1
3条回答
  •  粉色の甜心
    2021-01-28 05:05

    The basic issue you have is that CSS float works in a way that is different to how you want it to work.

    Another answer to your problem might be to use Javascript to hack it.

    There is a jQuery plug-in called Masonry which looks like it does what you're after. You can use float:left; for everything, and then use Masonry to close up the gaps.

    It would mean relying on a solution that isn't entirely CSS-based though, which probably isn't ideal - especially since I've already given you a working CSS-only solution.

    (also once you start using Javascript, you definitely need to fix your id vs class problem -- Javascript will disown you if you have all those elements with the same id)

提交回复
热议问题