css实现小图层定位于页面各个位置显示,当用户的鼠标经过小图层时,旁边会弹出一个大图层,可根据自己的需求来修改。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=gb2312"> <meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren"> <meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。"> <title>鼠标经过小图层弹出大图层效果_武鸣人</title> <style type="text/css"> *{margin:0;padding:0;} #www_wuming_ren{width:300px;height:300px;display:none;background:#FF99FF;position:absolute;z-index:2;} #wuming_ren div{position:absolute;background:#CCCCCC;width:50px;height:50px;} #wuming_ren div.wuming1{left:1000px;top:50px;} #wuming_ren div.wuming2{left:800px;top:500px;} #wuming_ren div.wuming3{left:10px;top:30px;} #wuming_ren div.wuming4{left:50px;top:650px;} #wuming_ren div.wuming5{left:500px;top:50px;} #wuming_ren div.wuming6{left:300px;top:300px;} #wuming_ren div.wuming7{left:1100px;top:700px;} #wuming_ren div.wuming8{left:300px;top:600px;} </style> </head> <body> <a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr> <!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。--> <script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script> <script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script> <div id="www_wuming_ren"><a href="https://www.wuming.ren" target="_blank">武鸣人</a>各种信息免费发布!</div> <div id="wuming_ren"> <div class="wuming1">武鸣人</div> <div class="wuming2">武鸣人</div> <div class="wuming3">武鸣人</div> <div class="wuming4">武鸣人</div> <div class="wuming5">武鸣人</div> <div class="wuming6">武鸣人</div> <div class="wuming7">武鸣人</div> <div class="wuming8">武鸣人</div> </div> <script type="text/javascript"> function getStyle(obj,name){ return obj.currentStyle?obj.currentStyle[name]:(document.defaultView.getComputedStyle(obj,"").getPropertyValue(name)) }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) for(var i=0;i<document.getElementById("wuming_ren").getElementsByTagName("div").length;i++){ document.getElementById("wuming_ren").getElementsByTagName("div")[i].onmouseover=function(){ var o=document.getElementById("www_wuming_ren"); var s=document.getElementById("wuming_ren"); if(!o.style.left)o.style.left=0; if(!o.style.top)o.style.top=0; var ow = getStyle(o,"width"); var oh = getStyle(o,"height"); var sl = getStyle(this,"left"); var st = getStyle(this,"top"); var sw = getStyle(this,"width"); var sh = getStyle(this,"height"); ow = parseInt(ow); oh = parseInt(oh); sl = parseInt(sl); st = parseInt(st); sw = parseInt(sw); sh = parseInt(sh); var x=(x<=ow+sw+10)?360:document.documentElement.clientWidth; var y=(y<=oh+sh+10)?360:document.documentElement.clientHeight; if(x < ow+sw){ o.style.left = sl+sw+10 + "px" }else{ o.style.left = (x-sl-10 > ow)?(sl+sw+10 + "px"):(sl-ow-10 + "px"); } if(y < ow+sw){ o.style.top = st+10 + "px" }else{ o.style.top = (y-st-10 > oh)?(st+10 + "px"):(st-oh-10+sh + "px"); } o.style.display="block"; } document.getElementById("wuming_ren").getElementsByTagName("div")[i].onmouseout=function(e){ var o=document.getElementById("www_wuming_ren"); o.style.display="none"; } }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) </script> </body> </html>
本文来自武鸣人网站,转载请注明出处