Forum Moderators: open
here is what i have so far
$ (function(){
var winHeight = $(window).height();
var contHeight = $('.content').css('height');$('#maincontent').css('height', winHeight);
console.log(contHeight);
});
the vars bring back the right info. how would i set up an if statement that says. if contHeight > winHeight then this:
$('#maincontent').css('height', contHeight);
$ (function(){
var winHeight = $(window).height();
var contHeight = $('.content').css('height');
if (contHeight > winHeight) {
$('#maincontent').css('height', contHeight);
} else {
$('#maincontent').css('height', winHeight);
}
console.log(contHeight);});
Or a possible alternative (no 'if' statement required, let Math get what is needed):
$ (function(){
var winHeight = $(window).height();
var contHeight = $('.content').css('height');$('#maincontent').css('height', Math.max(winHeight,contHeight));
console.log(contHeight);
});
Or even cleaner maybe:
$ (function(){
$('#maincontent').css('height', Math.max($(window).height(),$('.content').css('height')));
});
Thanks dood, I had too add some more variables but mathMax eventually worked. here is the final JS.
$ (function(){
var winHeight = $(window).height();
var contHeight = $('.content').css('height');
var uom = contHeight.slice(-2);
var num = parseFloat(contHeight, 10);
var contFin = num + 25;
$('#maincontent').css('height', Math.max(winHeight,contFin) + uom);
});
I needed to add 25 because of some padding. but thanks for the help! Now my divs will extend all the way to the bottom when the content doesn't fit. but if javascript is disabled i'm screwed...
but if javascript is disabled i'm screwed...