温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

BootStrap中动态模态框以及静态模态框的实现方法

发布时间:2020-10-22 16:08:25 来源:亿速云 阅读:170 作者:小新 栏目:web开发

这篇文章主要介绍BootStrap中动态模态框以及静态模态框的实现方法,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

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

代码如下:

动态模态框

<!DOCTYPE html>
<html>
<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>
                <div>
                    <div>bootstrap框架 <small>s</small>
                    </div>
                </div>
    <!-- 动态框 -->
<div>
    <!-- modal默认是隐藏的 -->
    <div>                  
        <div>
         <!-- 头部关闭按钮 -->
            <div>             
                <button type="button" class="close myclose" data-dismiss="modal"><span >&times</span></button>
                <div class="h4 modal-title">标题部分</div>
                <!-- 内容部分 -->
                <div>
                    <P>这是内容部分</P>
                </div>
                <!-- 页脚 -->
                <div>
                    <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>

静态模态框

<!DOCTYPE html>
<html>
<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>
        <div>
            <div>bootstrap框架 <small>s</small>
            </div>
           
         <!-- 静态模态框 官方有一个bug就是在写静态框的时候在按钮上要绑定同一个class-->
                <div>
                    <div>
                        <div>
                            <button type="button" class="close myclose" data-dismiss="modal">
                                <span>&times;</span>
                            </button>
                            <h4>Model标题</h4>                            
                     </div>
                     <!-- body部分 -->
                     <div>
                         <p>这是身体部分</p>
                     </div>
                     <!-- footer部分 -->
                     <div>
                         <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>

以上是BootStrap中动态模态框以及静态模态框的实现方法的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI