CSS height 100% issue

前端 未结 3 1753
深忆病人
深忆病人 2021-01-06 11:20

I know there are a lot of questions about a css 100% height problem. However I\'ve tried to follow the instructions there and still the height isn\'t 100%, so I thought I\'d

3条回答
  •  感动是毒
    2021-01-06 11:34

    A number of people suggested position:absolute; bottom:0;

    This can cause an issue if the content is taller than the container. The height will not increase so the content will no longer fit and can get cut off or result in ugly scroll bars.

    If you can give a fixed height to the container, this is ideal since the height:100% will then work on the child element. In case the content is too large, you can put a background on the child with overflow:visible on the parent, so the content still displays. This helps, but it can still break unless the child is the same width as the parent.

    If that doesn't work, I recommend using min-height in em or pixels. This will make sure the height fills the parent, and expands if the content is too long. This worked best for customer comments on www.baka.ca

提交回复
热议问题