Yoda says: A problem which only JavaScript can solve, you have.
http://jsfiddle.net/6MCLN/7/
css:
body {
background-color: #ff0000;
background: -ms-linear-gradient(top left, #d00 0%, #f33 50%, #611 100%);
background: linear-gradient(top left, #d00 0%, #f33 50%, #611 100%);
margin: 0;
overflow: hidden;
}
h1, nav, footer {
background-color: rgba(40, 40, 40, 0.4);
margin: 0;
padding: 10px;
}
section {
overflow-y: scroll;
padding: 10px;
}
The aforementioned JavaScript:
$(function () {
var thereIsNoTry = function () {
$('section').css({ height:
$(window).height() -
$('h1').height() -
$('nav').height() -
$('footer').height() -
parseInt($('h1').css('padding-top')) -
parseInt($('h1').css('padding-bottom')) -
parseInt($('nav').css('padding-top')) -
parseInt($('nav').css('padding-bottom')) -
parseInt($('footer').css('padding-top')) -
parseInt($('footer').css('padding-bottom')) -
parseInt($('section').css('padding-top')) -
parseInt($('section').css('padding-bottom'))
});
};
$(window).resize(thereIsNoTry);
thereIsNoTry();
});
EDIT
The big caveat to using javascript for this kind of thing is that if the DOM in the header changes without resizing the window, your 'section' has to be resized manually. The following additional JavaScript, however, will keep it up to date in most scenarios:
$(function () {
var thereIsNoTry = function () {
$('section').css({ height:
$(window).height() -
$('h1').height() -
$('nav').height() -
$('footer').height() -
parseInt($('h1').css('padding-top')) -
parseInt($('h1').css('padding-bottom')) -
parseInt($('nav').css('padding-top')) -
parseInt($('nav').css('padding-bottom')) -
parseInt($('footer').css('padding-top')) -
parseInt($('footer').css('padding-bottom')) -
parseInt($('section').css('padding-top')) -
parseInt($('section').css('padding-bottom'))
});
};
$(window).resize(thereIsNoTry);
thereIsNoTry();
//In case you're updating the DOM
$(document).ajaxSuccess(thereIsNoTry);
var oldAnimate = jQuery.fn.animate;
//In case the header can be animated
jQuery.fn.animate = function (properties, duration,
animation, easing) {
if (arguments.length == 4) {
return oldAnimate.call(this, properties,
duration, animation, easing);
}
if (arguments.length == 3) {
return oldAnimate.call(this, properties,
duration, animation);
}
if (arguments.length == 2 && typeof duration === 'object') {
var options = {
progress: function (animation, progress, remainingMs) {
if (duration.progress) {
duration.progress.call(this, animation,
progress, remainingMs);
}
thereIsNoTry();
}
}
var option = $.extend({}, duration, options);
return oldAnimate.call(this, properties, option);
}
if (arguments.length == 2) {
return oldAnimate.call(this, properties, {
duration: duration,
progress: thereIsNoTry
});
}
return oldAnimate.call(this, properties);
};
$('nav').animate({ height: '100px' }, { duration: 'slow' });
});
EDIT
Added overflow: hidden to BODY to prevent 'flickering' vertical scrollbar