日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

不同位置上弹窗变化

發(fā)布時間:2025/7/14 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 不同位置上弹窗变化 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
不同位置上彈窗變化 <!DOCTYPE html> <html> <head lang="en"><meta charset="UTF-8"><title></title><style>div{display: block;border:2px solid darkseagreen;background-color: greenyellow;color: gray;font-size: 14px;width: 126px;height: 76px;position: absolute;padding: 5px;/*top: 14px;*//*left: 0px;*/}.top{display: block;position: absolute;top: -14px;left: 57px;border-bottom: 14px solid darkseagreen;border-left: 8px solid transparent;border-right: 8px solid transparent;}.right{display: block;position: absolute;right: -14px;top: 32px;border-bottom: 8px solid transparent;border-left: 14px solid darkseagreen;border-top: 8px solid transparent;}.left{display: block;position: absolute;left: -14px;top: 32px;border-bottom: 8px solid transparent;border-right: 14px solid darkseagreen;border-top: 8px solid transparent;}.bottom{display: block;position: absolute;bottom: -14px;left: 57px;border-top: 14px solid darkseagreen;border-left: 8px solid transparent;border-right: 8px solid transparent;}</style> </head> <body> <!--/*在文檔中隨意點擊(充當(dāng)對按鈕的點擊)顯示彈框呈現(xiàn)樣式*/--> <div><p>隨意點擊彈出我,看看我有什么不同?</p><span class="top"></span> </div> <script> document.onclick = clickStat; function clickStat() {//確定點擊位置var e = arguments[0] || window.event;var x = e.clientX;var y = e.clientY;var w=window.innerWidth|| document.documentElement.clientWidth|| document.body.clientWidth;var h=window.innerHeight|| document.documentElement.clientHeight|| document.body.clientHeight;var o = {top: (y),left: (x),bottom: (h-y),right: (w-x)};alert("w="+w+";h="+h+";left="+ o.left+";"+"top="+ o.top+";"+"right="+ o.right+";"+"bottom="+ o.bottom);//設(shè)置彈框顯示樣式var popdiv = document.getElementsByTagName('div')[0];var arrowSpan = document.getElementsByTagName('span')[0];var popdivStyle = document.defaultView.getComputedStyle(popdiv, null);var arrowSpanStyle = document.defaultView.getComputedStyle(arrowSpan, null);var popH = parseFloat(popdivStyle.height.slice(0,-2))+14;var popW = parseFloat(popdivStyle.width.slice(0,-2))+14; // var arrowTop = parseFloat(arrowSpanStyle.top.slice(0,-2)); // var arrowLeft = parseFloat(arrowSpanStyle.left.slice(0,-2));//判斷彈框箭頭的方向和箭頭在彈框上的位置var topflag = 0,leftflag = 0,rightflag = 0,bottomflag = 0;if(o.bottom > popH){topflag = 1;if(o.right > popW && o.left <= popW){topflag = 0;leftflag = 1;}else if(o.right<=popW){topflag = 0;rightflag = 1;}else{topflag = 1;}}else{bottomflag = 1;}alert("topflag="+topflag+";leftflag="+leftflag+";rightflag="+rightflag+";bottomflag"+bottomflag);if(bottomflag){arrowSpan.setAttribute("class","bottom");popdiv.style.top = (o.top-popH)+"px";popdiv.style.left = o.left+"px";arrowSpan.style.top = "87px";}else if(leftflag){arrowSpan.setAttribute("class","left");popdiv.style.left = (o.left+14)+"px";if(o.top<40){popdiv.style.top = "0px";arrowSpan.style.top = (o.top-8)+"px";}else{popdiv.style.top = (o.top-40)+"px";arrowSpan.style.top = "32px";}}else if(rightflag){arrowSpan.setAttribute("class","right");popdiv.style.left = (o.left-popW-12)+"px";if(o.top<40){popdiv.style.top = "0px";arrowSpan.style.top = (o.top-8)+"px";}else{popdiv.style.top = (o.top-40)+"px";arrowSpan.style.top = "32px";}}else{arrowSpan.setAttribute("class","top");popdiv.style.top = (o.top+14)+"px";popdiv.style.left = o.left+"px";arrowSpan.style.top = "-14px";}// popdiv.style.display = popdiv.style.display=='none'?'block':'none'; // } </script> </body> </html>

?

posted on 2015-03-04 17:15 玲兒靈 閱讀(...) 評論(...) 編輯 收藏

轉(zhuǎn)載于:https://www.cnblogs.com/jymz/p/4313852.html

總結(jié)

以上是生活随笔為你收集整理的不同位置上弹窗变化的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。