Setting 100% height on an absolutely positioned element when the content expands past the window size

前端 未结 3 899
滥情空心
滥情空心 2021-02-15 04:46

So after reading Stack Overflow and the web, I\'ve gathered that there are two main tricks to achieving 100% height:

  1. Set height:100% on both the HTML and BODY
3条回答
  •  情话喂你
    2021-02-15 05:24

    Sorry, I missed the real question before and thought you wanted the window filled. If the issue is that the contents are longer than the window then what you need is to add position:relative to the body. http://jsfiddle.net/9FEne/7/

    What is happening is that when you absolutely position something it positions (and sizes) relative to the nearest positioned element. If you don't tell it to position to the body then it will position to the window.

提交回复
热议问题