Height of outer div not expanding with inner div

后端 未结 5 1888
遇见更好的自我
遇见更好的自我 2020-12-30 03:52

I have a bodyMain div of 100% width. Inside it is a body div 800px with auto margin(can I use \'body\' as id ?). Inside this are two divs bodyLeft and bodyRight 200px and 60

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-30 04:15

    This is a common issue when working with floats. There are a couple of common solutions:

    1. Add a div after the floats with clear: both

    2. Add the two floats into a container with the CSS attribute overflow: auto

    3. Make the parent element a float

    4. Using the :after CSS pseudo element with the CSS: .clearfix:after {content: "."; display: block; height: 0; clear: both; visibility: hidden;}

    5. Adding a set height to the parent element

    See this article

提交回复
热议问题