Expanding the parent container with 100% height to account for floated content

前端 未结 6 988
清酒与你
清酒与你 2020-11-30 21:58

I\'m struggling with a client project. All of my divs have no absolute positioning, height:100% for html, body, and conta

6条回答
  •  感动是毒
    2020-11-30 22:45

    If you have to use overflow:visible for some reason, there's other way to force container to stretch to contain all floated content. You have to put element with clear:both as a last container's elements. If you ignore ancient IEs (<8) you can do it with very simple css (vide https://css-tricks.com/snippets/css/clear-fix/):

    .your-container:after {
      content: "";
      display: table;
      clear: both;
    }
    

提交回复
热议问题