I am using bootbox.js from http://bootboxjs.com/examples.html and it is quite impressive. But I have an issue while setting up the location of the dialog box.
I want to place dialog box center of the screen. I am using this code but dialog box stays on top of the screen.
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'
});
Please advise how can set the dialog box center of the screen.
js is a small JavaScript library which allows you to create programmatic dialog boxes using Bootstrap modals, without having to worry about creating, managing, or removing any of the required DOM elements or JavaScript event handlers.
Pressing the ESC key or clicking close () dismisses the dialog and invokes the callback as if the user had clicked the Cancel button. Confirm dialogs require a callback function.
If you want a vertical centered bootbox modal via css3
.modal-open .modal {
display: flex !important;
align-items: center;
justify-content: center;
}
You can have more flexibility here: https://www.kirupa.com/html5/centering_vertically_horizontally.htm https://css-tricks.com/snippets/css/a-guide-to-flexbox/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With