I'm attempting to get a modal footer in bootstrap 4 to have multiple 100% width rows. So for the most basic bootstrap modal example below, is it possible to get the Close and Save changes buttons to be on different rows and both be 100% width?
<div class="modal fade" id="exampleModalLong" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">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>
The modal-footer is display:flex;. So the better way to align its elements (e.g. buttons) is by using flex rules. Bootstrap 4 provides new utilities classes to modify those flex rules (e.g. .justify-content- [modifier] ). So I think a better option should be as follows:
Multiple Modals on a Page - Bootstrap 4 Code Snippet (2021) - Bootstrap Creative Multiple Modals on a Page Bootstrap Code Snippet. Quickly jumpstart your next project with this Bootstrap CSS compatible code samples. See Demo Toggle navigation Shop HubSpot Themes Website Optimization Services Multiple Modals on a Page
Footer --> An advanced example of Bootstrap Footer. Components used: Floating social buttons , inline outline form, text , 4 column grid with links inside and copyright section . We also applied a dark background by using .bg-dark class.
With four responsive columns, this Bootstrap footer has empty links for whatever you need to include in your footer. In mobile, a "Top" button appears to push users back to the top of the page. CodePen Embed - Simple Responsive Bootstrap footer.
Yes for sure you can place two modal-footer
elements.
<div class="modal fade" id="exampleModalLong" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">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 col-lg-12" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
<div class="modal-footer">
<button type="button col-lg-12" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Then in your css add this
#exampleModalLong .modal-footer .btn{
width:100%;
}
Here you have a jsfillde link
A more "natural" way to do it would be to add
.modal-footer {
display: block;
}
It's the default display: flex
that makes the buttons share the same row.
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