Split Div Into 2 Columns Using CSS

后端 未结 14 1864
故里飘歌
故里飘歌 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条回答
  •  Happy的楠姐
    2020-11-29 18:57

    Floats don't affect the flow. What I tend to do is add a

    possibly some content

    at the end of the 'wrapping div' (in this case content). I can justify this on a semantic basis by saying that such a paragraph might be needed. Another approach is to use a clearfix CSS:

    #content:after {
      content: ".";
      display: block;
      height: 0;
      clear: both;
      visibility: hidden;
    }
    
    #content {
      display: inline-block;
    }
    /*  \*/
    * html #content {
      height: 1%;
    }
    
    #content {
      display: block;
    }
    /*  */
    

    The trickery with the comments is for cross-browser compatibility.

提交回复
热议问题