デフォルトの幅を持たない div 要素を水平方向に中央揃えするために jQuery を使用しています。次のコードを使用していますが、機能していません。誰かが理由を理解するのを手伝ってくれるなら、それは非常に役に立ちます。PS、高さのデフォルトの高さは 20 なので、-10px はそこから来ます。
var w = ($(".notec").width() + 51) / 2;
$(".buttons").css("margin", "-10px 0 0 -" + w + "px");
に関するセンタリング.notec
。要素がブロック要素として表示されている場合、幅は必要ありません。
var h = ($(".notec").height() - $(".buttons").height()) / 2;
$(".buttons").css("margin", h+"px auto 0 auto');
見てください:UI/API/1.8/Position http://bit.ly/IvUhLF
$(".overlay").hide();
$(".photo_hold").hover(
function () {
$(".overlay", $(this)).show();
$(".buttons", $(this)).position({
my: "center",
at: "center",
of: $(this)
});
},
function () {
$(".overlay", $(this)).hide();
}
);
変数をいじって、必要なことを実行させます