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,
topTwo=offsetTwo.top,
leftOne=offsetOne.left,
leftTwo=offsetTwo.left,
widthOne = objOne.width(),
widthTwo = objTwo.width(),
heightOne = objOne.height(),
heightTwo = objTwo.height();
var leftTop = leftTwo > leftOne && leftTwo < leftOne widthOne
&& topTwo > 탑원 && 탑투 < topOne heightOne,
rightTop = leftTwo widthTwo > leftOne && leftTwo widthTwo < leftOne widthOne
&& topTwo > 탑원 && 탑투 < topOne heightOne,
leftBottom = leftTwo > leftOne && leftTwo < leftOne widthOne
&& topTwo heightTwo > topOne && topTwo heightTwo < topOne heightOne,
rightBottom = leftTwo widthTwo > leftOne && leftTwo widthTwo < leftOne widthOne
&& topTwo heightTwo > topOne && topTwo heightTwo < topOne heightOne;
왼쪽으로 돌아가기Top || 오른쪽상단 || 왼쪽아래 || 오른쪽하단;
}
하나
두
3
div{
너비:200px;
높이:200px;
배경:#EEE;
}
#two{
위치:절대;
왼쪽:100px;
상단:50px;
배경:#F60;
}
다운로드
<머리>
JSCode 데모 <본문>
하나
두
3