JSCode
LoginResult JavaScript HTML CSS ALL 編輯分享
$("#result").text(isOverlap("one","two") "," isOverlap("one","三") "," isOverlap("二","三"));
function isOverlap(idOne,idTwo){
var objOne=$("#" idOne),
objTwo= $("#" idTwo),
offsetOne = objOne.offset(),
offsetTwo = objTwo.offset(),
topOne=offsetOne.top,
topTwooffsetTwo.top,
topTwooffsetTwo.top,
leftOne=offsetOne.left,
leftTwo=offsetTwo.left,
widthOne = objOne.width(),
widthTwo = objTwo.width(), heightOne = objOne. 🎜>heightTwo = objTwo.height();
var leftTop = leftTwo >;左一&& 左二&& topTwo >頂部一&& 頂部二&& topTwo >頂部一&& 頂部二leftBottom = leftTwo >左一&& 左二rightBottom = leftTwo widthTwo > leftOne && leftTwo widthTwo && topTwo heightTwo > topOne &wotopTwo 🎜>&& topTwo heightTwo > topOne &wotopTwo ||heightTwo;左下||右下;
}
一
二
;
三
;
div{
寬度:200px;
高度:200px;
背景:# EEE;
}
#two{
位置:絕對;
左:100px;
上:50px;
背景:#F60;
}
下載
背景:#F60;
}
下載
JSCode 示範
div{
寬度:200px;
高度:200px;
背景:#EEE;
}
#two{
位置:絕對;
左:100px;
上:50px;
背景:#F60;
}
樣式>
頭>
一
;
二
;
三
;
$("#result").text(isOverlap("一","二") "," isOverlap("一","三") "," isOverlap( "二","三")) ;
function isOverlap(idOne,idTwo){
var objOne=$("#" idOne),
objTwo=$("#" idTwo),
offsetOne = objOne.offset(),
offsetTwo = objTwo.offset(),
topOne=offsetOne.top,
topTwo=offsetTwo.top,
leftOne=offsetOne.left, 🎜>leftTwo=offsetTwo.left,
widthOne = objOne.width(),
widthTwo = objTwo.width(),
heightOne = objOne.height(wo. );
var leftTop = leftTwo >;左一&& 左二&& topTwo >頂部一&& 頂部二rightTop = leftTwo widthOne leftTwoftd
&& topTwo >頂部一&& 頂部二leftBottom = leftTwo >左一&& 左二&& topTwo heightTwo > leftOne widthOne
&& topTwo heightTwo > 頂= leftTwo widthTwo > leftOne && leftTwo widthTwo && topTwo heightTwo > topOne && topTwo heightTwo 回到左下上右🎜>回到左下一個高度一個; >}
腳本>
身體>
分享連結
嵌入您的頁面
分享到新浪
分享到QQ
作者:Artwl