how to align an invisible element to the center or how to find out the width and height of an invisible element?
var $top=($(window).height() - $('.main').outerHeight())/2;
var $left = ($(window).width() - $('.main').outerWidth())/2;
if ($top<0)$top=0;
$('.main ').css({
position:'absolute',
left: $left,
top: $top
});
but for invisible elements there is no height before rendering.....(((
so use
visibility: hidden
Comments