天天看点

浮层模板

//屏蔽输入,显示蒙板

function showMask(idName) {
    var obj = document.getElementById(idName);
    obj.style.width = document.body.clientWidth;
    obj.style.height = document.body.clientHeight;
    obj.style.display = "block";
}
           

//隐藏蒙板

function hideMask(idName) {
    document.getElementById(idName).style.display = "none";
}
           

//显示弹框

function showPop(idName) {
    showMask('mask');
    var width = 12;
    var height = 6;  
    var obj = document.getElementById(idName);
    obj.style.display = "block";
    obj.style.position = "absolute";
    obj.style.zindex = "10";
    obj.style.overflow = "hidden";
    obj.style.width = width + "rem";
    obj.style.height = height + "rem";
    obj.style.top = '50%';
    obj.style.left = '50%';
    obj.style.marginLeft = -width/2 + 'rem';
    obj.style.marginTop = -height/2 + 'rem';


}
           

//隐藏模板

function hidePop(idName) {
    hideMask('mask');
    //removeVoice();
    document.getElementById(idName).style.display = "none";
} 
           

调用方式

显示模板

showPop('tcc') //tcc是中间弹窗的id名
           

显示模板

hidePop('tcc') //tcc是中间弹窗的id名
           

ps:显示弹窗里面的数据都可以修改成适合自己的宽度大小,默认弹窗是上下居中显示的