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

筅森魡賤 提交于 2019-12-03 12:35:52

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.

Trav McKinney

You can use jQuery to achieve this trick

var h = $(window).height();
$('#yourdiv').height(h);

I would use javascript to assign the height and width equal to document's height and window's width respectively; I've modified your jsfiddle to demonstrate it here:

http://jsfiddle.net/9FEne/1/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!