zoukankan      html  css  js  c++  java
  • 原生js创建模态框(摘自:东窗凝残月 链接:https://www.cnblogs.com/dcncy/p/9076937.html)


    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Test</title>
    <style>
    #pageMask {
    visibility: hidden; //使pageMask元素不可见
    position: absolute; //定位pageMask元素
    left: 0px; //定位pageMask元素
    top: 0px; //定位pageMask元素
    100%;
    height:100%;
    text-align: center; //文本对其方式
    z-index: 1100; //指定一个元素的堆叠顺序
    ">#333;//设置背景色
    opacity: 0.6; //设置元素的透明度级别
    }
    #ModalBody{
    background: white; //设置背景
    50% !important;
    height: 50% !important;
    position:absolute; //定位ModalBody元素
    left: 25%;
    top: 25%;
    z-index: 1101; //指定元素的堆叠顺序
    border: 1px solid; //边框1px的实线
    display: none; //不可见
    }
    #closeModalBtn{
    position: static; //静态定位的元素不会受到top,bottom,left,right影响
    margin-top: 5px; //设置closeModalBtn元素的上部边距
    margin-right: 1%; //右部边距
    float: right; //右侧移动
    font-size: 14px; //字体大小
    background: #ccc000;
    cursor: pointer; //设置光标形态,pointer光标呈现为指示链接的指针(一只手)
    }
    </style>
    </head>
    <body>
    <div class="content">
    <h1>Test Modal</h1>
    <div id="pageMask"></div> <!--遮盖层-->
    <button class="showModalBtn" id="showModalBtn">Btn</button>
    <div> <!--主页面-->
    Page Content...
    </div>
    </div>

    <div id="ModalBody"> <!--模态框-->
    <button id="closeModalBtn" style="display: none;">Close</button>
    <div>Test Modal Body...</div>
    </div>

    <script>
    window.onload = function(){
    expandIframe();
    }
    function expandIframe(){
    var mask = document.getElementById("pageMask");
    var modal = document.getElementById("ModalBody");
    var closeBtn = document.getElementById("closeModalBtn");
    var btn = document.getElementById("showModalBtn"); btn.onclick = function(){ modal.style.display = (modal.style.display == "block")? "none" : "block"; closeBtn.style.display = (closeBtn.style.display == "block")? "none" : "block"; mask.style.visibility = (mask.style.visibility == "visible")? "hidden" : "visible"; } closeBtn.onclick = function(){ modal.style.display = (modal.style.display == "block")? "none" : "block"; closeBtn.style.display = (closeBtn.style.display == "block")? "none" : "block"; mask.style.visibility = (mask.style.visibility == "visible")? "hidden" : "visible"; } }</script></body></html>
  • 相关阅读:
    TRUNCATE TABLE 删除表中的所有行,而不记录单个行删除操作
    血腥!实况转播SQL注入全过程,让你知道危害有多大。
    DB2隔离级别设置
    使用解释工具分析SQL语句
    DB2的七种武器
    db2精华文档和论坛链接
    “饮水机”:形象比喻 深入浅出理解RAID
    DB2 数据库恢复测试
    IBM DB2 日常维护汇总
    镜像分割与高可用性灾难恢复
  • 原文地址:https://www.cnblogs.com/anrangesi/p/9106248.html
Copyright © 2011-2022 走看看