more.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>镜像站@更多示例 - layer弹层组件</title>
  6. </head>
  7. <link rel="stylesheet" href="../../../res.layui.com/layui/dist/css/layui.css" tppabs="http://res.layui.com/layui/dist/css/layui.css" media="all">
  8. <link rel="stylesheet" href="../../../res.layui.com/static/css/global.css" tppabs="http://res.layui.com/static/css/global.css" media="all">
  9. <link rel="stylesheet" href="../demo.css" tppabs="http://www.layui.com/layer/demo.css?v=2021321" media="all">
  10. <style>
  11. .box{width:728px;}
  12. .box .layui-btn{margin-top: 10px; margin-left: 0; margin-right: 7px;}
  13. .box p a,
  14. .box pre a{color: #01AAED;}
  15. </style>
  16. <body>
  17. <div class="header">
  18. <div class="layui-main">
  19. <a class="logo" href="../../index.html" tppabs="http://www.layui.com/">
  20. <img src="../../../res.layui.com/static/images/layui/logo.png" tppabs="http://res.layui.com/static/images/layui/logo.png" alt="layui">
  21. </a>
  22. <ul class="layui-nav">
  23. <li class="layui-nav-item layui-this">
  24. <a href="../index.html" tppabs="http://www.layui.com/layer/">layer</a>
  25. </li>
  26. </ul>
  27. </div>
  28. </div>
  29. <div class="clear box layer-main">
  30. <a href="javascript:;" class="layui-btn">多窗口模式,层叠置顶</a>
  31. <a href="javascript:;" method="confirmTm" class="layui-btn">配置一个透明的询问框</a>
  32. <a href="javascript:;" method="notice" class="layui-btn">示范一个公告层</a>
  33. <a href="javascript:;" method="offset" data-type="t" class="layui-btn layui-btn-normal">上弹出</a>
  34. <a href="javascript:;" method="offset" data-type="r" class="layui-btn layui-btn-normal">右弹出</a>
  35. <a href="javascript:;" method="offset" data-type="b" class="layui-btn layui-btn-normal">下弹出</a>
  36. <a href="javascript:;" method="offset" data-type="l" class="layui-btn layui-btn-normal">左弹出</a>
  37. <a href="javascript:;" method="offset" data-type="lt" class="layui-btn layui-btn-normal">左上弹出</a>
  38. <a href="javascript:;" method="offset" data-type="lb" class="layui-btn layui-btn-normal">左下弹出</a>
  39. <a href="javascript:;" method="offset" data-type="rt" class="layui-btn layui-btn-normal">右上弹出</a>
  40. <a href="javascript:;" method="offset" data-type="rb" class="layui-btn layui-btn-normal">右下弹出</a>
  41. <a href="javascript:;" method="offset" data-type="auto" class="layui-btn layui-btn-normal">居中弹出</a>
  42. <p style="margin: 10px 0;">Tips:为了更清晰演示,每触发上述一个例子之前,都会关闭所有已经演示的层</p>
  43. <pre id="demo1" class="layui-code" style="display: block;"><p>//多窗口模式,层叠置顶
  44. layer.open({
  45. type: 2 //此处以iframe举例
  46. ,title: '当你选择该窗体时,即会在最顶端'
  47. ,area: ['390px', '330px']
  48. ,shade: 0
  49. ,offset: [ //为了演示,随机坐标
  50. Math.random()*($(window).height()-300)
  51. ,Math.random()*($(window).width()-390)
  52. ]
  53. ,maxmin: true
  54. ,content: 'settop.html'
  55. ,btn: ['继续弹出', '全部关闭'] //只是为了演示
  56. ,yes: function(){
  57. $(that).click(); //此处只是为了演示,实际使用可以剔除
  58. }
  59. ,btn2: function(){
  60. layer.closeAll();
  61. }
  62. ,zIndex: layer.zIndex //重点1
  63. ,success: function(layero){
  64. layer.setTop(layero); //重点2
  65. }
  66. });</p>
  67. <p>//配置一个透明的询问框
  68. layer.msg('大部分参数都是可以公用的<code><</code>br>合理搭配,展示不一样的风格', {
  69. time: 20000, //20s后自动关闭
  70. btn: ['明白了', '知道了', '哦']
  71. });
  72. </p>
  73. //示范一个公告层
  74. layer.open({
  75. type: 1
  76. ,title: false //不显示标题栏
  77. ,closeBtn: false
  78. ,area: '300px;'
  79. ,shade: 0.8
  80. ,id: 'LAY_layuipro' //设定一个id,防止重复弹出
  81. ,resize: false
  82. ,btn: ['火速围观', '残忍拒绝']
  83. ,btnAlign: 'c'
  84. ,moveType: 1 //拖拽模式,0或者1
  85. ,content: '&lt;div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">内容&lt;br>内容&lt;/div>'
  86. ,success: function(layero){
  87. var btn = layero.find('.layui-layer-btn');
  88. btn.find('.layui-layer-btn0').attr({
  89. href: 'http://www.layui.com/'
  90. ,target: '_blank'
  91. });
  92. }
  93. });
  94. //边缘弹出
  95. layer.open({
  96. type: 1
  97. ,offset: 't' //具体配置参考:<a href="../../doc/modules/layer.html#offset" tppabs="http://www.layui.com/doc/modules/layer.html#offset" target="_blank">offset参数项</a>
  98. ,content: '&lt;div style="padding: 20px 80px;">内容&lt;/div>'
  99. ,btn: '关闭全部'
  100. ,btnAlign: 'c' //按钮居中
  101. ,shade: 0 //不显示遮罩
  102. ,yes: function(){
  103. layer.closeAll();
  104. }
  105. });
  106. </pre>
  107. </div>
  108. <div class="layui-footer footer footer-index">
  109. <div class="layui-main">
  110. <p>&copy; <a href="../../index.html" tppabs="http://www.layui.com/">「本站仅为 layui 文档保留的镜像站点,与官方无关」</a> MIT license</p>
  111. </div>
  112. </div>
  113. <script src="../../../other/jquery/1.12.3/jquery.min.js" tppabs="http://cdn.staticfile.org/jquery/1.12.3/jquery.min.js"></script>
  114. <script src="../../../res.layui.com/layui/release/layer/dist/layer.js-v=351-1.js" tppabs="http://res.layui.com/layui/release/layer/dist/layer.js?v=330"></script>
  115. <script>
  116. var demo = {
  117. confirmTm: function(){
  118. layer.closeAll();
  119. layer.msg('大部分参数都是可以公用的<br>合理搭配,展示不一样的风格', {
  120. time: 20000, //20s后自动关闭
  121. btn: ['明白了', '知道了', '哦']
  122. });
  123. }
  124. ,notice: function(){
  125. layer.open({
  126. type: 1
  127. ,title: false //不显示标题栏
  128. ,closeBtn: false
  129. ,area: '300px;'
  130. ,shade: 0.8
  131. ,id: 'LAY_layuipro' //设定一个id,防止重复弹出
  132. ,resize: false
  133. ,content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #e2e2e2; font-weight: 300;">你知道吗?亲!<br>layer ≠ layui<br><br>layer只是作为Layui的一个弹层模块,由于其用户基数较大,所以常常会有人以为layui是layerui<br><br>layer虽然已被 Layui 收编为内置的弹层模块,但仍然会作为一个独立组件全力维护、升级。<br><br>我们此后的征途是星辰大海 ^_^</div>'
  134. ,btn: ['火速围观', '残忍拒绝']
  135. ,btnAlign: 'c'
  136. ,moveType: 1 //拖拽模式,0或者1
  137. ,success: function(layero){
  138. var btn = layero.find('.layui-layer-btn');
  139. btn.find('.layui-layer-btn0').attr({
  140. href: '../../index.html'/*tpa=http://www.layui.com/*/
  141. ,target: '_blank'
  142. });
  143. }
  144. });
  145. }
  146. ,offset: function(othis){
  147. var type = othis.data('type')
  148. ,text = othis.text();
  149. layer.open({
  150. type: 1
  151. ,offset: type //具体配置参考:http://www.layui.com/doc/modules/layer.html#offset
  152. ,id: 'LAY_demo'+type //防止重复弹出
  153. ,content: '<div style="padding: 20px 100px;">'+ text +'</div>'
  154. ,btn: '关闭全部'
  155. ,btnAlign: 'c'
  156. ,shade: 0
  157. ,yes: function(){
  158. layer.closeAll();
  159. }
  160. });
  161. }
  162. };
  163. $('.layui-btn').on('click', function(){
  164. var othis = $(this), method = othis.attr('method');
  165. var demo1 = $('#demo1'), p = demo1.find('p').eq(othis.index());
  166. demo[method] ? demo[method].call(this, othis) : new Function('that', p.html())(this);
  167. });
  168. </script>
  169. </body>
  170. </html>