I am using the following Jquery script to center the container div in the middle of the window. The problem comes when the user has a resolution that is smaller than the container, as when the site loads the top of the div is chopped off. How can I set the function only to trigger if the browser size or resolution is bigger than the container div ?.
<script>
$(window).load(function(){
var positionContent = function () {
var width = $(window).width(); // the window width
var height = $(window).height(); // the window height
var containerwidth = $('.container').outerWidth(); // the container div width
var containerheight = $('.container').outerHeight(); // the container div height
$('.container').css({position:'absolute',
left: ($(window).width() - $('.container').outerWidth())/2,
top: ($(window).height() - $('.container').outerHeight())/2 });
};
//Call this when the window first loads
$(document).ready(positionContent);
//Call this whenever the window resizes.
$(window).bind('resize', positionContent);
});
</script>