码迷,mamicode.com
首页 > 其他好文 > 详细

弹框和遮罩

时间:2016-05-11 14:47:20      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:

 

 遮罩可以用一个半透明的高度和宽度等于页面100%的div来做。

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>东方证券</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="format-detection" content="email=no"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"/>
<style>
    *, :after, :before {
        -webkit-tap-highlight-color: transparent
    }

    blockquote, body, dd, div, dl, dt, fieldset, form, h1, h2, h3, h4, h5, h6, input, legend, li, ol, p, td, textarea, th, ul {
        margin: 0;
        padding: 0
    }

    body{
        background: #f2f4f3;
        color: #333333;
    }
    .content-box{
    }
    li {
        list-style: none;
    }
    .am-flexbox {
        text-align: left;
        display: -webkit-box;
        display: -webkit-flex;
        -webkit-box-align: center;
        -webkit-align-items: center;
        position: relative;
    }

    .am-flexbox .am-flexbox-item, .am-flexbox2 .am-flexbox-item {
        -webkit-box-sizing: border-box;
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        width: 20px;
        position: relative;
    }
    .weui_cell {
        padding: 5px 15px;
        font-size: 16px;
        position: relative;
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-align: center;
        -webkit-align-items: center;
        -ms-flex-align: center;
        align-items: center;
        background: #ffffff;
    }
    .btn {
        min-width: 75px;
        height: 35px;
        line-height: 35px;
        font-size: 18px;
        color: #ffffff;
        text-align: center;
        border-radius: 4px;
        background: #c70e16;
    }
    .weui_cell:after {
        content: " ";
        position: absolute;
        left: 0;
        bottom:-1px;
        width: 100%;
        height: 1px;
        border-bottom: 1px solid #D9D9D9;
        color: #D9D9D9;
        -webkit-transform-origin: 0 0;
        -ms-transform-origin: 0 0;
        transform-origin: 0 0;
        -webkit-transform: scaleY(0.5);
        -ms-transform: scaleY(0.5);
        transform: scaleY(0.5);
        z-index: 100;
    }
    .am-mg-10{
        margin: 0 10px;
    }
    .am-footer {
        position: fixed;
        left: 0;
        bottom: 10px;
        width: 100%;
        text-align: center;
        z-index: 1000;
    }
    .am-footer .btn{
        margin: 0 15px;
    }
    
    /*弹框遮罩*/
    html,body{height:100%;}
    .dialog{
        position: relative;
        top:150px;
        border:3px solid #c70e16;
        background:white;
        height:150px;
        width:80%;
        margin-left:auto;
        margin-right:auto;
        text-align:center;
        border-radius:7px;
        z-index:10000;
    }
    .dialog_line{
        margin-top:40px;
        margin-bottom:20px;
    }
    .dialog .btn{
        width:35%;
        margin-left:auto;
        margin-right:auto;
    }
    .dialog #password{
        background:transparent;
        border:1px solid #DAD3D3;
        height:23px;
        margin-left:10px;
        border-radius:4px;
    }
    .mask{
        background: #9797A5;
        height: 100%;
        width: 100%;
        opacity: 0.8;
        z-index: 9999;
        position: fixed;
        top: 0px;
    }
</style>
</head>
<body>
<div class="content-box">
    <ul class="itme itme3  weui_cells" id="weui_cells">
        <li class="am-flexbox weui_cell">
            <div class="am-flexbox-item">融资融券-00613899</div>
            <div class="btn" onclick="showDialog(this)">签约</div>
        </li>
    </ul>
</div>
<footer class="am-footer">
    <div class="btn am-mg-10" onclick="login()">登录签约账号</div>
</footer>

<script type="text/javascript">
    //对话框
    function showDialog(obj){
        if(document.getElementById(dialog)) return;
        btn = obj;

        var dialog = document.createElement(div);
        dialog.className = "dialog";
        dialog.id = "dialog";
        dialog.innerHTML = "<div class=‘dialog_line‘><label>密码:</label><input type=‘password‘ id=‘password‘/></div><div class=‘btn am-mg-10‘ onclick=‘send()‘>确认</div>"
        mask();
        document.body.appendChild(dialog);
    }
    
    //遮罩
    function mask(){
        var mask = document.createElement(div);
        mask.className = "mask";
        mask.id = "mask";
        document.body.appendChild(mask);
        mask.onclick = function(){
            removeDialog();
            removeMask();
        }
    }

    
    function send(){
        //发送签约解约请求
        
        //关闭弹框
        removeDialog();
        removeMask();
    }
    
    function removeDialog(){
        var dialog = document.getElementById(dialog);
        if(dialog)dialog.parentNode.removeChild(dialog);
    }
    
    function removeMask(){
        var mask = document.getElementById(mask);
        if(mask)mask.parentNode.removeChild(mask);
    }
    
    //===================================================================
    String.prototype.trim=function(){
        return this.replace(/(^\s*)|(\s*$)/g,‘‘);
    }
</script>
</body>
</html>

 

弹框和遮罩

标签:

原文地址:http://www.cnblogs.com/barker/p/5481637.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!