本篇文章给大家带来的内容是关于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 >×</span></button> <div class="h3 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>×</span> </button> <h3>Model标题</h3> </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中动态模态框以及静态模态框的代码实现的详细内容。更多信息请关注PHP中文网其他相关文章!