bootstrap4如何设置模态框


本文摘自PHP中文网,作者(*-*)浩,侵删。

模态框是覆盖在父窗体上的子窗体。通常,目的是显示来自一个单独的源的内容,可以在不离开父窗体的情况下有一些互动。子窗体可提供信息交互等。

例如,通过点击按钮打开模态框。(推荐学习:Bootstrap视频教程)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

<!DOCTYPE html>

<html>

<head>

  <title>Bootstrap 实例</title>

  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/css/bootstrap.min.css">

  <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>

  <script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script>

  <script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/js/bootstrap.min.js"></script>

</head>

<body>

 

<div class="container">

  <h2>模态框实例</h2>

  <!-- 按钮:用于打开模态框 -->

  <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">

    打开模态框

  </button>

    

  <!-- 模态框 -->

  <div class="modal fade" id="myModal">

    <div class="modal-dialog">

      <div class="modal-content">

    

        <!-- 模态框头部 -->

        <div class="modal-header">

          <h4 class="modal-title">模态框头部</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-secondary" data-dismiss="modal">关闭</button>

        </div>

    

      </div>

    </div>

  </div>

   

</div>

 

</body>

</html>

我们可以通过添加 .modal-sm 类来创建一个小模态框,.modal-lg 类可以创建一个大模态框。

尺寸类放在 <div>元素的 .modal-dialog 类后 :

更多Bootstrap相关技术文章,请访问Bootstrap教程栏目进行学习!

以上就是bootstrap4如何设置模态框的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

浅谈bootstrap如何自定义侧边导航栏样式

bootstrap怎么删除图标

bootstrap简介以及怎样部署安装(介绍)

vue cli3引入bootstrap的方法介绍

bootstrap的构成模块是什么

bootstrap怎么让图片自适应屏幕

bootstrap有react版吗

bootstrap有什么优点

html如何引用bootstrap

spss可以做bootstrap

更多相关阅读请进入《bootstrap》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...