Ho trovato questa funzione:
codice:
jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
return this;
}
ma applicata al mio script non va
codice:
$(function() {
$("#button").toggle(
function() {
$("#game").animate({width: 1300, height:700}, 500);
// $('#game').attr('style', 'position:absolute; background-color:yellow; left:50%; margin-left:0px;');
$("#game").center();
},
function() {
$("#game").animate({width: <?php echo $row_gioco['larghezza']; ?>, height:<?php echo $row_gioco['altezza']; ?>}, 500);
}
);
});