Hi!
Can anyone tell me where I am going wrong... I am using the following to vertically align a div by setting the margin-top, using the (window).height. 625 is the height of the Div being centered...
This works in Firefox but IE7 doesn't set the margin-top until you resize the browser window.
The test site is at http://guylloyd.co.uk
Any thought would be amazingly appreciated!
Martin
jQuery.noConflict();
jQuery(document).ready(function () {
jQuery(function(){
var $marginTop = ((jQuery(window).height() - 625) / 2 + 'px');
if(jQuery(window).height() > 625){
jQuery('body').css({'margin-top': $marginTop});
}
});
jQuery(window).resize(function(){
var $marginTop = ((jQuery(window).height() - 625) / 2 + 'px');
if(jQuery(window).height() > 625){
jQuery('body').css({'margin-top': $marginTop});
}
});
});