画面の中央にポップアップ ウィンドウを表示したいのですが、marginTop プロパティを使用するとウィンドウが表示されません。marginTop プロパティを削除すると、常に左上隅に表示されます。私は php 5.4 を使用しています。私は何を間違っていますか?
function show_popup(id) {
if (document.getElementById){
obj = document.getElementById(id);
if (obj.style.display == "none") {
obj.style.marginTop = 20%; //if i remove this line it works
obj.style.display = "";
}
}
}