http://bootboxjs.com/examples.htmlのbootbox.jsを使用していますが、非常に印象的です。しかし、ダイアログボックスの場所を設定する際に問題が発生します。
ダイアログボックスを画面の中央に配置したい。このコードを使用していますが、ダイアログボックスが画面の上部に表示されたままになります。
bootbox.alert('Danger!!').find('.modal-content').css({
'background-color': '#f99',
'font-weight': 'bold',
color: '#F00',
'top': '50%',
'margin-top': function() {
return -(box.height() / 2);
},
'font-size': '2em',
'font-weight': 'bold'
});
画面中央のダイアログボックスの設定方法を教えてください。
モーダルはすでに水平方向の中央に配置されています。垂直中心のモーダルが必要な場合は、これがうまくいくことを願っています
bootbox.alert('Danger!!' ).find('.modal-content').css({
'background-color': '#f99',
'font-weight' : 'bold',
'color': '#F00',
'font-size': '2em',
'margin-top': function (){
var w = $( window ).height();
var b = $(".modal-dialog").height();
// should not be (w-h)/2
var h = (w-b)/2;
return h+"px";
}
});
あなたの例に従ってこの答えを与える。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加