balanced alternating column layout in CSS3

前端 未结 6 1717
无人共我
无人共我 2021-02-08 04:32

I\'m trying create a balanced (2-) column-layout.

The content is not text but blocks and varies in height. The content should be placed alternatingly left and right, as

6条回答
  •  余生分开走
    2021-02-08 04:47

    PURE CSS SOLUTION:

    Add the following to your css file:

    ol.context li:nth-child(even) {
    float: right;
    }
    

    DO NOT change your html or anything else.

    Result in FF:

    Firefox rendering

    --

    How it Works

    Instead of floating all your elements "left" and creating gaps, we float each container according to the side/column the element they reside in.

提交回复
热议问题