当前位置:   article > 正文

Bootstrap之模态框(提示框)_模态提示框完成

模态提示框完成

1 效果图

Bootstrap的模态框可以用作,操作的提示、表单弹出窗口等。


2 代码

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>模态框测试</title>
  5. <script src="../../Scripts/jquery-2.2.0.js" type="text/javascript"></script>
  6. <script src="../../Scripts/bootstrap.js" type="text/javascript"></script>
  7. <link href="../../Styles/bootstrap.css" rel="stylesheet" type="text/css" />
  8. </head>
  9. <body>
  10. <!--
  11. data-toggle:触发器
  12. data-target:目标
  13. -->
  14. <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  15. 模态框测试
  16. </button>
  17. <!--
  18. tabindex:设置键盘中TAB键在控件中的移动顺序,即焦点的顺序,默认为0,-1表示此元素被忽略。
  19. -->
  20. <div class="modal fade" id="myModal" tabindex="-1">
  21. <div class="modal-dialog" ><!-- 模块会话 -->
  22. <div class="modal-content">
  23. <div class="modal-header">
  24. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  25. <span aria-hidden="true"> ×</span>
  26. </button>
  27. <h4 class="modal-title" id="myModalLabel">模块标题</h4>
  28. </div>
  29. <div class="modal-body">
  30. <p>内容主体</p>
  31. </div>
  32. <div class="modal-footer">
  33. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  34. <button type="button" class="btn btn-primary">保存</button>
  35. </div>
  36. </div><!-- /.model-content -->
  37. </div><!-- /.model-dialog -->
  38. </div><!-- /.modal -->
  39. </body>
  40. </html>

以上代码由两部分组成:
按钮:data-toggle和data-target属性是必备属性,前者声明了按钮的类型,后者什么了对应的模块(即模态框)。
模态框:div的嵌套为
modal--》modal-dialog--》modal-content--》modal-header(存放标题)、modal-body(存放内容)、modal-footer(存放按钮)。

3 使用

在实际使用中,如果是作为提示框使用,应将模态框部分放在一个公共的页面中。不同的提示只需修改modal-body中的内容,而不需要写多个模态款(表单的除外)。
js控制
  1. function hintModal(bodyTest) {
  2. console.info("执行方法");
  3. $("#hintModalBody").html(bodyTest);
  4. $("#hintModal").modal('show');
  5. }





声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/80877
推荐阅读
相关标签
  

闽ICP备14008679号