Click here to Skip to main content
Click here to Skip to main content

Set height of a div to full screen

By , 25 Dec 2011
 

Here is how to set the height of a div to full screen:

min-height:expression( document.body.clientHeight +’px’);
 
If your website is jQuery enabled, the same can be achieved by:
 
$('#yourHtmlElementId').attr('height',$(window).height());
 
NOTE: The prime reason behind posting this trick was that 'height:100%;' does not work with IE 8 browser. So if any alternative is posted, I would request the authors to test it in IE 8 compatibility mode in IE 9.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

aspnet_regiis -I
Web Developer
India India
Member
Software developer by profession, working for a service and product based organisation in Pune, India.
 
Career graph:
Software Programmer since 2002.
Web Developer in ASP.NET since 2004.
 
Interests:
I love reading the blogs and articles of technology experts. I love codeproject and stackoverflow .
 
I love to share knowledge and help the programmers. I appreciate if some body corrects my code or my concepts which helps me learn.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralRe: Direct from Microsoft website ("About Dynamic Properties" ur...memberGladToBeGrey14 Nov '11 - 3:02 
GeneralThe prime reason behind posting this trick was that 'height:...memberB Birajdar1 Dec '11 - 3:45 
GeneralInsufficient info and it doesn't workmemberjoekecalo21 Nov '11 - 21:43 
Generalcan you tell how can we get the height of screen when we hav...memberspydeehunk7 Nov '11 - 16:48 
GeneralRe: Yes. The javascript will get the height of the client browse...memberB Birajdar7 Nov '11 - 22:35 
GeneralNot really, no. CSS expressions were unique to IE, and were...memberGladToBeGrey7 Nov '11 - 12:05 
GeneralRe: CSS expressions are still valid. I have tested it in IE 8 an...memberB Birajdar14 Nov '11 - 2:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 25 Dec 2011
Article Copyright 2011 by aspnet_regiis -I
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid