Search code examples
htmlbootstrap-4bootstrap-modal

How to add text and button in bootstrap modal footer?


I'm trying to add some text in the bootstrap modal footer, however the output looks like 2 divs side by side which I don't want. Below is the code :

<div class="modal fade" id="itiModal" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
        <div class="modal-header">
        <h4 class="modal-title">Day Wise data</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        </div>
        <div class="modal-body"> </div>
        <div class="modal-footer">
        <button type="button" class="btn btn-dark" data-dismiss="modal">Close</button>
        Entire or partial data collected from Wikipedia.
        </div>
        </div>
    </div>
</div>

And the output looks like this:
unexpected
I want the text to appear below the buttons. I've tried putting the text in P/span tags.


Solution

  • based on questioner want to make buttons align right and text below and left align:

    enter image description here

    heres full code:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <title>Bootstrap Example</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
      <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
      <style>
        .modal-footer{display: block}
      </style>
    </head>
    <body>
    
    <div class="jumbotron text-center">
      <h1>Bootstrap 4</h1>
      <p>Resize this responsive page to see the effect!</p> 
      <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#itiModal">
        Open modal
      </button>
    </div>
      
    
      <div class="modal fade" id="itiModal" role="dialog">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <h4 class="modal-title">Day Wise data</h4>
              
              <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>
            <div class="modal-body">
              Modal body..
            </div>
            <div class="modal-footer">
              <div class="text-right">
                <button type="button" class="btn btn-dark">Bookmark</button>
                <button type="button" class="btn btn-dark">Details</button>
                <button type="button" class="btn btn-dark" data-dismiss="modal">Close</button>
              </div>
              <p class="text-left">Entire or partial data collected from Wikipedia.</p>
            </div>
          </div>
        </div>
      </div>
    </body>
    </html>