Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap 4 create modal footer with multiple rows

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">&times;</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>
like image 289
Shaun Poore Avatar asked Jul 14 '17 14:07

Shaun Poore


People also ask

How to align the buttons on the modal footer in Bootstrap?

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:

Can you have multiple modals on a page with bootstrap?

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

What is Bootstrap footer example?

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.

How many responsive columns are in a bootstrap footer?

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.


2 Answers

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">&times;</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

like image 166
Edison Biba Avatar answered Sep 22 '22 06:09

Edison Biba


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.

like image 25
Karima Kadaoui Avatar answered Sep 24 '22 06:09

Karima Kadaoui