JS+CSS实现可拖拽的漂亮圆角特效弹出层完整实例
本文实例讲述了JS+CSS实现可拖拽的漂亮圆角特效弹出层的方法。分享给大家供大家参考。具体如下:
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <htmlxmlns="http://www.w3.org/1999/xhtml"> <head> <metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/> <title>JS+CSS实现的可拖拽的漂亮圆角效果的弹出层</title> <style> body{ margin:0px; padding:0px; font-size:14px; } #t{ position:absolute; float:left; left:0px; top:0px; } #a{ float:left; } .al{ opacity:0.80; filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=80,finishOpacity=100); } .al2{ opacity:0.00; filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0,finishOpacity=100); } U{ DISPLAY:block; OVERFLOW:hidden; HEIGHT:1px } U.f1{ background-color:#5cc; BACKGROUND:#5cc; MARGIN:0px3px } U.f2{ background-color:#5cc; BORDER-RIGHT:#5cc2pxsolid; MARGIN:0px1px; BORDER-LEFT:#5cc2pxsolid } U.f3{ background-color:#5cc; BORDER-RIGHT:#5cc1pxsolid; MARGIN:0px1px; BORDER-LEFT:#5cc1pxsolid } .d_top{ clear:both; overflow:hidden; background-color:#5cc; height:29px; vertical-align:bottom; } .d_topa{ float:right; margin-top:5px; margin-right:13px; padding-top:3px; width:18px; color:red; background-color:#789; text-decoration:none; font-weight:bold; text-align:center; vertical-align:middle; } .d_topspan{ float:left; font-size:13px; margin-left:15px; margin-top:8px; } .d_body{ BORDER-RIGHT:#5cc3pxsolid; BORDER-LEFT:#5cc3pxsolid; padding:10px; height:200px; background-color:#fff; } .d_foot{ clear:both; overflow:hidden; background-color:#5cc; height:2px; } </style> <scripttype="text/javascript"> function$(id){returndocument.getElementById(id);} functionshow(id){ vart=$(id); t.style.width=document.body.clientWidth; t.style.height=document.body.clientHeight; window.onresize=function(){ t.style.width=document.body.clientWidth; t.style.height=document.body.clientHeight; } $(id).style.display=""; } functioncl(id){ $(id).style.display="none"; } functionmoveEvent(e,id){ varisIE=(document.all)?true:false; drag=true; xx=isIE?event.x:e.pageX; yy=isIE?event.y:e.pageY; L=document.getElementById(id).offsetLeft; T=document.getElementById(id).offsetTop; document.onmousemove=function(e){ if(drag){ x=isIE?event.x:e.pageX; if(x<0)x=0; y=isIE?event.y:e.pageY; if(y<0)y=0; document.getElementById(id).style.left=L-xx+x; document.getElementById(id).style.top =T-yy+y; } } document.onmouseup=function(){ drag=false; } } window.onscroll=function(){ $("back_div").style.width=document.body.scrollWidth; $("back_div").style.height=document.body.scrollHeight; } </script> </head> <body> <divid="a"style="position:absolute;left:300px;top:200px;"> <ahref="javascript:"onClick="show('t')">点这里弹出圆角效果的div</a><ahref='https://www.nhooo.com/'target='_blank'><u>对话框</u></a>!</div> <divid="t"style="display:none;"> <divstyle="width:100%;height:100%;z-index:-1;position:absolute;float:left;background-color:#555;overflow:hidden;"class="al"id="back_div"> <iframestyle="position:absolute;left:0px;top:0px;left:0px;bottom:0px;float:left;z-index:-1;margin:0px;padding:0px;"frameborder="0"scrolling="no"width="100%"height="2000px;"class="al2"id="ifr"></iframe> </div> <DIVstyle="WIDTH:500px;position:absolute;float:left;top:25%;left:30%;z-index:999;clear:both;overflow:hidden;"id="t_div"> <iframestyle="position:absolute;left:0px;top:0px;left:0px;bottom:0px;float:left;z-index:-1;margin:0px;padding:0px;"frameborder="0"scrolling="no"width="100%"height="2000px;"class="al2"id="ifr"></iframe> <Uclass="f1"></U><Uclass="f2"></U><Uclass="f3"></U> <divclass="d_top"onMouseDown="moveEvent(event,'t_div')"> <span>欢迎光临</span> <ahref="javascript:"onClick="cl('t')">×</a> </div> <DIVclass="d_body">欢迎光临:毛票票 </DIV> <divclass="d_foot"></div> <Uclass="f3"></U><Uclass="f2"></U><Uclass="f1"></U> </DIV> </div> </body> </html>
希望本文所述对大家的javascript程序设计有所帮助。