这篇文章主要为大家展示了“BootStrap如何实现动态模态框及静态模态框”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“BootStrap如何实现动态模态框及静态模态框”这篇文章吧。
代码如下:
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" rel="external nofollow" rel="external nofollow" > <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="h3">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 >×</span></button> <div class="h4 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="#" rel="external nofollow" 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" rel="external nofollow" rel="external nofollow" > <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="h3">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>×</span> </button> <h4>Model标题</h4> </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>
以上是“BootStrap如何实现动态模态框及静态模态框”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。