zoukankan      html  css  js  c++  java
  • jquery弹窗遮罩

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>jquery弹窗遮罩</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <style type="text/css">
            body
            {
                background#ffffff;
                padding0px;
                margin0px;
            }
            bodythtdinputbuttontextarea
            {
                font-family"宋体";
                font-size12px;
            }
            
            .over_main
            {
                backgroundwhite;
                positionabsolute;
                width600px;
                height400px;
                border1px solid lightblue;
                margin10px;
                overflowauto;
            }
            .over_main p
            {
                margin0px;
                padding3px;
                background#BCDAF0;
            }
            .over_products
            {
                padding-top5px;
                padding-left10px;
            }
            .over_searchResults li
            {
                list-stylenone;
            }
            
            .over_close
            {
                floatright;
                margin-top-18px;
                padding-right5px;
                cursorpointer;
            }
            .over_cover
            {
                backgroundgray;
                positionabsolute;
                top0px;
                left0px;
                opacity0.75;
            }
        </style>
    </head>
    <body>
        <input type="button" value="弹窗遮罩" id="test" />
        <div class="over_main">
            <p>
                选择商品</p>
            <span class="over_close">关闭</span>
            <div class="over_products">
                按
                <select id="selectItem">
                    <option>商品名称</option>
                    <option>商品Id</option>
                    <option>SiebelId</option>
                    <option>淘宝商家编码</option>
                    <option>淘宝商家Sku编码</option>
                </select>
                <input type="text" id="TxtSearchKeyWord" style="width: 200px;" />
                <input type="button" id="btnSearChchooseProducts" value="查询"></input>
                <div class="over_searchResults">
                    <ul>
                        <li>没找到符合条件的任何记录!</li></ul>
                </div>
            </div>
        </div>
        <div class="over_cover">
        </div>
        <script type="text/javascript">
            $(function () {
                $("#test").click(function () {
                    adjust();
                });
                $(".over_cover").click(function () {
                    showMask(false);
                });
                $(".over_close").click(function () {
                    showMask(false);
                });
            });
            function showMask(isShow) {
                var winW = $(window).width();
                var winH = $(window).height();
                $(".over_cover").css("width", winW + "px");
                $(".over_cover").css("height", winH + "px");
                $(".over_cover").css("background""gray");
                if (isShow) {
                    $(".over_main").show();
                    $(".over_cover").show();
                } else {
                    $(".over_main").hide();
                    $(".over_cover").hide();
                }
            }
            function adjust() {
                //取得当前宽度和高度
                var w = $(".over_main").css("width").replace(/px/g, "");
                var h = $(".over_main").css("height").replace(/px/g, "");
                //定位这个盒子,相对于窗口垂直居中
                var winW = $(window).width();
                var winH = $(window).height();
                var top = (winH / 2) - (h / 2);
                top = top < 0 ? 0 : top;
                var left = (winW / 2) - (w / 2);
                left = left < 0 ? 0 : left;
                //遮罩层
                showMask(true);
                $(".over_main").css("top", top + "px");
                $(".over_main").css("left", left + "px");
                $(".over_main").css("z-index""1");
            }
        </script>
    </body>
    </html>

    效果图:


  • 相关阅读:
    ubuntu Server 16.04 LTS 安装odoo
    linux常用命令大全
    sql 百万级数据库优化方案
    FreeSpire.XLS的使用
    备份集中的数据库与现有的数据库不同解决方案
    图片延迟加载的实现
    亚马逊菜单应用例子
    提取吗
    linux内核学习网站
    phpexcel1
  • 原文地址:https://www.cnblogs.com/zhangqs008/p/3618455.html
Copyright © 2011-2022 走看看