If it is possible Bootstrap 4 Modal box opens center of any screen. I am using bootstrap 4 modal box within modal box and it has always open top of page so please help me how to inner modal box open on center of any resolution, I am sending you screenshot https://prnt.sc/vod0q7.
Asked
Active
Viewed 65 times
-2
-
1Can you share your code – Vishal Nov 23 '20 at 11:48
-
Sorry i am unable to share you all code but i'll provide you screenshots. https://prnt.sc/vod7d9 after clicking on update button again one popup opens https://prnt.sc/vod969, but when i am clicking on below button then popup opens top of screen and it looks https://prnt.sc/vod9h0 – Anny Nov 23 '20 at 11:56
3 Answers
0
yes, add class modal-dialog-centered
to the modal dialog
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
...
</div>
</div>
</div>

ibrahim s
- 297
- 1
- 7
-
Yes i'have tried this above solution https://prnt.sc/vodf6q but didn't work – Anny Nov 23 '20 at 12:01
0
Used Bootstrap Vertically centered model. Add .modal-dialog-centered
to .modal-dialog
to vertically center the modal.
Full code here
Boostrap docs
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalCenterTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>

mhhabib
- 2,975
- 1
- 15
- 29
0
According to the Bootstrap docs
You can achieve it by adding the class modal-dialog-centered

giovaniZanetti
- 452
- 4
- 7
-
-
You could try to use flexbox : #myModal { display: flex; align-items: center; justify-content: center; } – giovaniZanetti Nov 23 '20 at 12:44