Split Div Into 2 Columns Using CSS

后端 未结 14 1844
故里飘歌
故里飘歌 2020-11-29 18:01

I have been attempting to split a div into two columns using CSS, but I have not managed to get it working yet. My basic structure is as follows:

14条回答
  •  抹茶落季
    2020-11-29 18:47

    None of the answers given answer the original question.

    The question is how to separate a div into 2 columns using css.

    All of the above answers actually embed 2 divs into a single div in order to simulate 2 columns. This is a bad idea because you won't be able to flow content into the 2 columns in any dynamic fashion.

    So, instead of the above, use a single div that is defined to contain 2 columns using CSS as follows...

    .two-column-div {
     column-count: 2;
    }
    

    assign the above as a class to a div, and it will actually flow its contents into the 2 columns. You can go further and define gaps between margins as well. Depending on the content of the div, you may need to mess with the word break values so your content doesn't get cut up between the columns.

提交回复
热议问题