admin管理员组

文章数量:1323715

For my last project I use Material Design for the website right now I switch to Bootstrap. Right now I'm looking for a way on how to create the bootstrap modal display actions to the user on the bottom of a screen. They still act the same as regular modals. I am looking for a modal that act like the Bottom Sheet Modal of materializecss. Is this possible for a bootstrap to do it? Or there are existing way to do it?

For my last project I use Material Design for the website right now I switch to Bootstrap. Right now I'm looking for a way on how to create the bootstrap modal display actions to the user on the bottom of a screen. They still act the same as regular modals. I am looking for a modal that act like the Bottom Sheet Modal of materializecss. Is this possible for a bootstrap to do it? Or there are existing way to do it?

Share Improve this question asked Apr 8, 2017 at 1:53 user7825127user7825127
Add a ment  | 

2 Answers 2

Reset to default 5

Yes, it is, but you need to change the modal css a little bit:

Note: the only change you need to do is adding style to the element class="modal-dialog"

<!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://maxcdn.bootstrapcdn./bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis./ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn./bootstrap/3.3.7/js/bootstrap.min.js"></script>
  </head>
  <body>

  <div class="container">
    <h2>Modal Example</h2>
    <!-- Trigger the modal with a button -->
    <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

    <!-- Modal -->
    <div class="modal fade" id="myModal" role="dialog" >
      <div class="modal-dialog" style="position:absolute;bottom:0;margin:0;width:100%;">

        <!-- Modal content-->
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">Modal Header</h4>
          </div>
          <div class="modal-body">
            <p>Some text in the modal.</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          </div>
        </div>

      </div>
    </div>

  </div>

  </body>
</html>

Example from: https://www.w3schools./bootstrap/bootstrap_modal.asp

With Bootstrap 5, you can use Offcanvas ponents. It's just like Bottom Sheet Modal in materializecss.

<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasBottom" aria-controls="offcanvasBottom">Toggle bottom offcanvas</button>

<div class="offcanvas offcanvas-bottom" tabindex="-1" id="offcanvasBottom" aria-labelledby="offcanvasBottomLabel">
  <div class="offcanvas-header">
    <h5 class="offcanvas-title" id="offcanvasBottomLabel">Offcanvas bottom</h5>
    <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
  </div>
  <div class="offcanvas-body small">
    ...
  </div>
</div>

本文标签: javascriptBootstrap Modal at Bottom SheetStack Overflow