Home > Web Front-end > JS Tutorial > body text

Sharing the effect of creating a centered mask layer with jquery_jquery

WBOY
Release: 2016-05-16 16:58:52
Original
1210 people have browsed it

复制代码 代码如下:





遮罩演练






   

           

  •            
           

  •    






   

       
           

  •            

  •            

  •        
       





    shadow.js

    复制代码 代码如下:

    shadow_list=[];
    function showAddTopic(cb){
        var input_container=$('#content-container-templet').clone();
        input_container.removeAttr('id');
         var shadow=$('
    ').addClass('shadow-wrapper').append(input_container);
         shadow.appendTo(document.body);
         shadow_list.push(shadow);
         $('.sure',shadow).on('click',function(){
             var val=$('.input-li input',shadow).val();
             cb(val);
             hideAddTopic();
         });
         $('.cancel',shadow).on('click',function(){
             hideAddTopic();
         });
    }

    function hideAddTopic(){
        if(shadow_list.length>0){
            var shadow=shadow_list.pop();
            shadow.remove();
        }
    }

    component2.css

    复制代码 代码如下:

    html,body{
            padding:0px;
            margin: 0px;
            width: 100%;
            height: 100%;
            overflow:hidden;
        }
        ul,li{
            padding:0px;
            margin: 0px;
            list-style:none;
        }
       input,textarea{
        vertical-align:middle;
        border:none;
       }
        .layout-container{
            position:absolute;
            top:0px;
            height:100%;
            overflow:auto;
        }
       .left-container{
           left: 0px;
           width:20%;
           border:solid 5px #52BE7F;
       }
       .right-container{
           right:0px;
           width:80%;
       }
       .shadow-wrapper{
           position: absolute;
           width:100%;
           height: 100%;
       }
       .topic-title li  span{
           height:30px;
           line-height:30px;
           vertical-align:middle;
       }
       .topic-title  .fun{
           float:right;
       }
       .topic-input-div{
           position: absolute;
           left: 50%;
           top:50%;
           height:200px;
           width: 400px;
           margin-top:-120px ;
           margin-left:-210px;
           padding:20px 10px;
       }
       .topic-input-ul{
           vertical-align: middle;
           position:absolute;
           width:380px;
           height:2em;
           left: 50%;
           top:50%;
           margin-top: -1em;
           margin-left: -190px;
       }
        .topic-input-ul li{
            line-height: 2em;

            display:inline-block;
             *display:inline;
       }
       .topic-input-ul .input-li{
           width:40%;
       }
       .topic-input-ul .btn-li{
           width: 15%;
       }
    Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template