css 底部薄板的 Bootstrap 模态

yc0p9oo0  于 2023-03-25  发布在  Bootstrap
关注(0)|答案(1)|浏览(147)

对于我的最后一个项目,我使用Material Design的网站,现在我切换Bootstrap.现在我正在寻找一种方法,如何创建引导模态显示动作的用户在屏幕的底部.他们仍然表现得像普通的模态一样.我正在寻找一个模态,像materializecss的Bottom Sheet Modal.这是否可能由 Bootstrap 来完成?或者有现有的方法来完成?

ax6ht2ek

ax6ht2ek1#

是的,它是,但是你需要稍微改变一下模态css:
注意:您需要做的唯一更改是为元素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.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/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>

示例来自:https://www.w3schools.com/bootstrap/bootstrap_modal.asp

相关问题