People who have used bootstrap modal (modal box) components have a kind of confusion, so how can a good pop-up box not be centered vertically? Happen to do a EIT project, because some of the framework of this project to follow the nttdata of some rules, so the use of the bootstrap this Dongdong, the first encounter this dongdong, there is a lot of resistance, feel bad, but I think with the other pop-up box really no different. Talk less, cut to the chase, bootstrap the problem of vertical center, because the pop-up I got is not vertically centered, but top 10%, but the page is long, it seems particularly disgusting.
The solution looks like this:
1. In CSS, find
. modal.fade.in {
top:10%
}
This style, modify it OK, because the CSS is global, but also can be defined in the page to a modal (height) position, the following methods:
<style>
#myModal-help
{
top:300px
}
</style>
#myModal-help This is the modal ID, so the setting is OK.
2. In JS,
I'm using bootstrap-modal.js (if you're using a bootstrap.js or a bootstrap.min.js, you can, but you need to find the location).
Found in JS (red is the method I added):
var left = ($ (document.body). Width ()-that. $element. Width ())/2;
Console.log (left);
$element
. addclass (' in ')
. attr (' Aria-hidden ', false)
. css ({
left:left,
top:top,
Margin: "0 auto"
});
That.enforcefocus ()
Once found, add the red to the OK, so that all the pop-up boxes are centered vertically.
The above is a small set to introduce the Bootstrap pop-up box (modal) vertical center of the problem and solution of the relevant knowledge, hope to help everyone, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!