Alex Rivera | Logout

How to set div height to 100% of user's monitor resolution?

Asked 2011-03-03T03:37:21.500
10

height: 100% in CSS obviously doesn't work. So is there any other CSS or JavaScript/jQuery solutions to this problem? Please advise.

Edit
Report

3 Answers

3

With jQuery, you could use:

$('div.class').css('height', $(window).height()+'px');
answered 2011-03-03T05:14:58.800
3

Pure css

#container {
position:absolute;
top:0;
right:0;
bottom:0;
left:0;
}

Good Luck

Or javacript Jquery:

Ready (not innerHeight in ie8):

$(document).ready( function(){
var heightwindow = $(document).height();
$('#container').css('height', heightwindow+'px');
});

resize window :

$(window).resize(function() {
var heightwindow = $(document).height();
$('#container').css('height', heightwindow+'px');
});
answered 2013-07-26T15:20:51.800
0

I don't think you can get the monitor's resolution with any web technology. What you an do is use Javascript to get the browser's height and set the height property of div in the css. This post might help for getting the height.

answered 2011-03-03T03:42:10.393

Your Answer