admin管理员组

文章数量:1323737

I have an absolute positioned div that I need to get to to fill the entire document for a background to a modal window.

I can get it to fill the window but when there is a scroll bar it doesnt fill the area that is currently visible.

This is my current code:

position:absolute;   
top:0;
left:0;
height:100%;
min-height:100%;

By the way I can get it to fill the document horizontally.

I have an absolute positioned div that I need to get to to fill the entire document for a background to a modal window.

I can get it to fill the window but when there is a scroll bar it doesnt fill the area that is currently visible.

This is my current code:

position:absolute;   
top:0;
left:0;
height:100%;
min-height:100%;

By the way I can get it to fill the document horizontally.

Share Improve this question edited Jan 11, 2011 at 10:49 manycheese asked Jan 11, 2011 at 10:41 manycheesemanycheese 3,6852 gold badges20 silver badges11 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 9

Give the div position:fixed and top,bottom,left,right 0

See here: http://jsfiddle/sQLPr/

edit - removed the following line

  • and it's parent (probably body) position:relative
div.covered {position: fixed; top:0; left:0; bottom:0; right:0;}

test it here: http://jsfiddle/meo/kGUYG/2/

Position absolute is gonna scroll when you scroll the page unless you find a JS solution. You need to use position fixed so the element does not scroll when the content does.

Put it in a table with 100% width and that's all

本文标签: javascriptModal Div to fill entire window including below foldStack Overflow