<i id='6WSxl'><tr id='6WSxl'><dt id='6WSxl'><q id='6WSxl'><span id='6WSxl'><b id='6WSxl'><form id='6WSxl'><ins id='6WSxl'></ins><ul id='6WSxl'></ul><sub id='6WSxl'></sub></form><legend id='6WSxl'></legend><bdo id='6WSxl'><pre id='6WSxl'><center id='6WSxl'></center></pre></bdo></b><th id='6WSxl'></th></span></q></dt></tr></i><div id='6WSxl'><tfoot id='6WSxl'></tfoot><dl id='6WSxl'><fieldset id='6WSxl'></fieldset></dl></div>

<small id='6WSxl'></small><noframes id='6WSxl'>

        • <bdo id='6WSxl'></bdo><ul id='6WSxl'></ul>

      1. <legend id='6WSxl'><style id='6WSxl'><dir id='6WSxl'><q id='6WSxl'></q></dir></style></legend>

      2. <tfoot id='6WSxl'></tfoot>

        html 模态弹出窗口

        时间:2023-06-13

                <tbody id='SysFY'></tbody>

              <small id='SysFY'></small><noframes id='SysFY'>

              <i id='SysFY'><tr id='SysFY'><dt id='SysFY'><q id='SysFY'><span id='SysFY'><b id='SysFY'><form id='SysFY'><ins id='SysFY'></ins><ul id='SysFY'></ul><sub id='SysFY'></sub></form><legend id='SysFY'></legend><bdo id='SysFY'><pre id='SysFY'><center id='SysFY'></center></pre></bdo></b><th id='SysFY'></th></span></q></dt></tr></i><div id='SysFY'><tfoot id='SysFY'></tfoot><dl id='SysFY'><fieldset id='SysFY'></fieldset></dl></div>

                <legend id='SysFY'><style id='SysFY'><dir id='SysFY'><q id='SysFY'></q></dir></style></legend>
              • <tfoot id='SysFY'></tfoot>
                  <bdo id='SysFY'></bdo><ul id='SysFY'></ul>
                  本文介绍了html 模态弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何为以下代码制作一个简单的模式弹出窗口.点击背景时,模式弹出窗口不应该消失.

                  How to make a simple modal popup for the following code.And on click on the background the modal popup should not disappear.

                  <html>
                  <input type="textarea"></input>
                  </html>
                  

                  推荐答案

                  这是一个纯 JavaScript 示例:

                  Here's a plain-JavaScript example:

                  var modal = document.getElementById('modal');
                  var shade = document.getElementById('shade');
                  document.getElementById('start').onclick = function() {
                    modal.style.display = shade.style.display = 'block';
                  };
                  document.getElementById('close').onclick = function() {
                    modal.style.display = shade.style.display = 'none';
                  };
                  
                  // This code is a workaround for IE6's lack of support for the
                  // position: fixed style.
                  //
                  if (!('maxHeight' in document.body.style)) {
                    function modalsize() {
                      var top = document.documentElement.scrollTop;
                      var winsize = document.documentElement.offsetHeight;
                      var docsize = document.documentElement.scrollHeight;
                      shade.style.height = Math.max(winsize, docsize) + 'px';
                      modal.style.top = top + Math.floor(winsize / 3) + 'px';
                    };
                    modal.style.position = shade.style.position = 'absolute';
                    window.onscroll = window.onresize = modalsize;
                    modalsize();
                  }

                  body {
                    margin: 0;
                  }
                  
                  #shade,
                  #modal {
                    display: none;
                  }
                  
                  #shade {
                    position: fixed;
                    z-index: 100;
                    top: 0;
                    left: 0;
                    width: 100%;
                    height: 100%;
                  }
                  
                  #modal {
                    position: fixed;
                    z-index: 101;
                    top: 33%;
                    left: 25%;
                    width: 50%;
                  }
                  
                  #shade {
                    background: silver;
                    opacity: 0.5;
                    filter: alpha(opacity=50);
                  }

                  <div id="shade"></div>
                  <div id="modal">
                    <textarea rows="5" cols="25"></textarea>
                    <button id="close">Close</button>
                  </div>
                  
                  <p>
                    <button id="start">Start</button>
                  </p>

                  您可以从那里进行各种改进,例如修复 IE z-indexing 的 iframe hack,或将其封装在可重用对象中,但这是完成的基本方式.

                  There are various improvements you can make from there, such as iframe hacks to fix IE z-indexing, or encapsulating it in a reusable object, but that's the basic way it's done.

                  这篇关于html 模态弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:灰色框出现在模态框中嵌入的谷歌地图的部分中 下一篇:如何知道模态框(警报、提示、确认...)是否已在 javascript 中被禁用?

                  相关文章

                  <tfoot id='IV6su'></tfoot>
                  <legend id='IV6su'><style id='IV6su'><dir id='IV6su'><q id='IV6su'></q></dir></style></legend>
                    • <bdo id='IV6su'></bdo><ul id='IV6su'></ul>

                      <i id='IV6su'><tr id='IV6su'><dt id='IV6su'><q id='IV6su'><span id='IV6su'><b id='IV6su'><form id='IV6su'><ins id='IV6su'></ins><ul id='IV6su'></ul><sub id='IV6su'></sub></form><legend id='IV6su'></legend><bdo id='IV6su'><pre id='IV6su'><center id='IV6su'></center></pre></bdo></b><th id='IV6su'></th></span></q></dt></tr></i><div id='IV6su'><tfoot id='IV6su'></tfoot><dl id='IV6su'><fieldset id='IV6su'></fieldset></dl></div>

                      <small id='IV6su'></small><noframes id='IV6su'>