底部的Bootstrap模态

时间:2017-04-08 01:53:28

标签: javascript html css twitter-bootstrap materialize

对于我的上一个项目,我现在使用 Material Design 为网站切换 Bootstrap 。现在,我正在寻找一种如何在屏幕底部为用户创建引导模态显示操作的方法。它们仍然与常规模态相同。我正在寻找一个类似于materializecss Bottom Sheet Modal的模态。 引导程序可以执行此操作吗?或者有现成的方法吗?

1 个答案:

答案 0 :(得分:1)

是的,确实如此,但你需要稍微改变一下模态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