BootStrap的动态模态框及静态模态框

2018-08-13 07:44:29来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

1.要用bootStrap这个框架就必须要重载它的class类,也就是说class要一样

代码如下:

有疑问的可以在下面留言,欢迎大家一起交流

1.1动态模态框

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="bootstrap-3.3.7/css/bootstrap.css">
    <script src="bootstrap-3.3.7/js/jquery.min.js"></script>
    <script src="bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="bootstrap-3.3.7/js/docs.min.js"></script>

</head>
<body>
        <div class="container">
                <div class="page-header">
                    <div class="h2">bootstrap框架 <small>s</small>
                    </div>
                </div>
    <!-- 动态框 -->
<div class="modal">
    <!-- modal默认是隐藏的 -->
    <div class="modal-dialog">                  
        <div class="modal-content">
         <!-- 头部关闭按钮 -->
            <div class="modal-header">             
                <button type="button" class="close myclose" data-dismiss="modal"><span >&times</span></button>
                <div class="h3 modal-title">标题部分</div>
                <!-- 内容部分 -->
                <div class="modal-body">
                    <P>这是内容部分</P>
                </div>
                <!-- 页脚 -->
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary myclose" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-warning myclose">save</button>
                </div>
            </div>
        </div>
    </div>
    
</div>
    <a href="#" class="btn btn-success" id="show">显示对话框</a>
        </div>
</body>
</html>
<script>
    $(function(){
        $('#show').click(function(){
            $('.modal').modal('show')
        })
    })
</script>

 

1.2静态模态框

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="bootstrap-3.3.7/css/bootstrap.css">
    <script src="bootstrap-3.3.7/js/jquery.min.js"></script>
    <script src="bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="bootstrap-3.3.7/js/docs.min.js"></script>
</head>
<body>
    <div class="container">
        <div class="page-header">
            <div class="h2">bootstrap框架 <small>s</small>
            </div>
           
         <!-- 静态模态框 官方有一个bug就是在写静态框的时候在按钮上要绑定同一个class-->
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close myclose" data-dismiss="modal">
                                <span>&times;</span>
                            </button>
                            <h3>Model标题</h3>                            
                     </div>
                     <!-- body部分 -->
                     <div class="modal-body">
                         <p>这是身体部分</p>
                     </div>
                     <!-- footer部分 -->
                     <div class="modal-footer">
                         <button class="btn btn-info myclose" data-dismiss="modal">close</button>
                         <button class="btn btn-primary myclose">save</button>
                     </div>
                    </div>
                </div>
           </div>
 </div> 
      </div>
    </div>
</body>
</html>
<script>
    $(function(){
        $('.myclose').click(function(){
            $('.modal-dialog').css('display','none')
        })
    })
</script>

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:marquee标签的使用

下一篇:es6 解构赋值