2014-07-26 2 views
-3

두 개의 div를 서로 위에 두어 보았습니다. 과 같은 콘텐츠 크기가 무엇인지 알지 못하기 때문에 견인 div를 보냈습니다. 위치 : 절대 twew를 설정하는 절대적 위치 그 컨테이너의 왼쪽 상단에내용이 절대 위치 일 때 내용이 DIV로 확장됩니다.

문제는 다음과 같습니다 컨테이너가 내가 부모에게 아이의 높이를 설정하는 몇 가지 jQuery를 시도 절대 div의 로 확장 dosent하지만, 절대 자식 DIV 나던 너비 또는 높이가 있기 때문에 코드가 처음부터 영향을받지 않음

$("div.selectionTabs.inner").css("height",$("div.selectionTabs.inner>div.productsTab.under").height()+"px"); 
+0

''position : relative''보다는''position : relative''를 고려할 수 있습니다. – sarbbottam

답변

0

이 시도 :

function placeElementOver(e1,e2){ 
e1.style.position = "absolute"; 
e1.style.left = e2.getClientRects()[0].left; 
e1.style.top = e2.getClientRects()[0].top; 
e1.style.width = e2.clientWidth; 
e1.style.height = e2.clientHeight; 
} 

그럼 그냥 init 함수에

placeElementOver(div2,div1); 

를 호출합니다.