CSS Multiple multi-column divs

前端 未结 2 1433
无人及你
无人及你 2021-01-21 17:04

I have a bunch of items (text, image, mixed content, etc) that I want to display. The user can define what row and what column that item appears in. For example, in row 1, there

2条回答
  •  既然无缘
    2021-01-21 17:49

    They sure can! The basic effect (it sounds like) you're looking for is like so:

    #wrapper {
        width: 900px;
    }
        
    .item {
        height: 200px;
        width: 200px;
        margin: 10px;
        float: left;
    }
    Something
    Something else
    Something cool
    Something sweet
    Something just ok

    So what this would do is set up a fixed-width container (the #wrapper) and fill it with "blocks". Because each has a fixed width and is floated left, they'll line up in a grid. Because of the width/margin I've set for each, you should get 4 per row. If you need spacers, just put in blank DIVs to get the content on the right row/column.

提交回复
热议问题