SORU
17 EKİM 2008, Cuma


Kullanarak ekranda bir DİV ortalamak için bir WordPress kullanmak

Nasıl ekranın ortasında <div> ayarı hakkında jQuery kullanarak gidebilirim?

CEVAP
17 EKİM 2008, Cuma


Bu fonksiyon yardımı olur bir WordPress kullanmak için işlevler eklemek istiyorum:

jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2)   
                                                $(window).scrollTop())   "px");
    this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2)   
                                                $(window).scrollLeft())   "px");
    return this;
}

Şimdi yazabiliriz:

$(element).center();

Demo: Fiddle (eklendi parametre ile)

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Hudson Music

    Hudson Music

    13 Mart 2007
  • Caramella Girls

    Caramella Gi

    19 Mayıs 2008
  • Trulia

    Trulia

    29 Kasım 2006