Jquery original popup layer folding effect click on the popup layer

  • 2020-03-30 02:19:46
  • OfStack

The pop-up layer effect is used on many websites. Today, I will sort out a small effect used in the recent project. Click and collapse to pop up a layer for the user to fill in information. Pop-up layer code is jq dynamic creation, everyone is not the same way to write, requirements are not the same, all the choices to meet their own can.

<h1 class="bm"><a href="javascript:;"> I want to sign up </a></h1> 

*{ margin:0; padding:0;} 
body{ font:14px 'Microsoft YaHei'; color:#555;} 
li{ list-style:none;} 
.layer_bg{ position:fixed; top:0; left:0; width:100%; height:100%; background:#000; z-index:10; display:none;} 
.layer_item{ position:fixed; left:50%; top:50%; width:600px; margin-left:-300px; display:inline; overflow:hidden; background:#fff; z-index:11;} 
.layer_item .layer_title{ float:left; width:100%; height:75px; line-height:75px; overflow:hidden; background:#FF4E00;} 
.layer_item .layer_title h1{ float:left; font-weight:normal; font-size:35px; text-indent:20px; color:#fff;} 
.layer_item .layer_title a{ float:right; width:75px; height:75px; line-height:65px; text-align:center; font-size:60px; color:#fff; text-decoration:none; background:#535961;} 
.layer_item ul{ float:left; width:100%; padding:10px 0;} 
.layer_item ul li{ float:left; width:100%; line-height:35px; padding:10px 0; overflow:hidden;} 
.layer_item ul li span{ float:left; width:100px; text-indent:20px; text-align:right; padding-right:10px;} 
.layer_item ul li span b{ color:Red;} 
.layer_item ul li .layer_txt{ float:left; width:300px; height:23px; line-height:23px; padding:5px; border:1px solid #dfdfdf;} 
.layer_item ul li #message{ width:400px; height:150px;} 
.layer_item .layer_btn{ float:left; width:100%; padding-bottom:40px;} 
.layer_item .layer_btn .layer_submit_btn{ float:left; width:100px; height:40px; text-align:center; overflow:hidden; background:#FF4E00; color:#fff; margin-left:110px; display:inline; border:none; font:14px 'Microsoft YaHei'; line-height:40px; } 

$(function () { 
var layer_bg = '<div class="layer_bg"></div>'; //layer_bg 
var layer = '<div class="layer_item">'; //layer_item 
layer += '<div class="layer_title"><h1> I want to sign up </h1><a href="javascript:;" title=" Shut down ">x</a></div>'; //layer_title 
layer += '<ul>'; //layer_cont 
layer += '<li><span> Real name <b>*</b> : </span><input type="text" class="layer_txt" name="name"></li>'; 
layer += '<li><span> Mobile phone <b>*</b> : </span><input type="text" class="layer_txt" name="tel"></li>'; 
layer += '<li><span>QQ : </span><input type="text" class="layer_txt" name="qq"></li>'; 
layer += '<li><span> The registration number <b>*</b> : </span><input type="text" class="layer_txt" name="num"></li>'; 
layer += '<li><span> Message: </span><textarea id="message" rows="2" cols="20" class="layer_txt"></textarea></li>'; 
layer += '</ul>'; //layer_cont end 
layer += '<div class="layer_btn"><input type="submit" class="layer_submit_btn" value=" submit " /></div>'; 
layer += '</div>'; //layer_item end 
var winW = $(window).width(); 
var winH = $(window).height(); 
var objH = $('.layer_item').height(); 
var objW = $('.layer_item').width(); 
$('.layer_item').css({ 'height': 0 }); 
$('.bm').click(function () { 
$('.layer_item').animate({ 'height': objH, 'marginTop': -objH / 2 },500); 
$('.layer_title a').on('click', function () { 
$('.layer_item').animate({ 'height': 0, 'marginTop': 0 }, 200, function () { 

< img SRC = "border = 0 / / files.jb51.net/file_images/article/201403/201403121612021.gif? 2014212161219 ">  

Related articles: