2012-05-25 3 views
0

나는 부모 div가 있는데, 그 안에는 약 6 개의 div가 나란히 있습니다. 모든 것은 jQuery를 추가 할 때를 제외하고는 잘 동작한다.css parent div 및 child div가 제대로 재생되지 않습니다.

이제 부모 div는 이전처럼 확장되지 않습니다. 나는 부모 div를 relative으로 만들고 자식 div는 absolute으로 만들었지 만, 부모 div는 그냥 늘리지 않을 것입니다.

jQuery를

$(".child").click(function() { 
    var mypos, otherpos, $this; 

    // Move to the target element 
    $this = $(this); 
    pos = $this.offset(); 
    otherpos = $('selector_for_other_element').offset(); 
    pos.left = otherpos.left - pos.left; 
    pos.top = otherpos.top - pos.top; 
    $this.animate({ 
    left: pos.left + "px", 
    top: pos.top + "px" 
    }); 
}); 

CSS

<style type="text/css"> 
    .child{ 
    width: 250px; 
    height: auto; 
    float: left; 
    padding: 10px 5px 10px 0px; 
    background-color: #fff; 
    position: absolute 
    } 
    .parent { 
    width: 770px; 
    height: auto; 
    float: left; 
    padding: 10px 0px 0px 10px; 
    background-color: #fff; 
    position: relative; 
    overflow: none; 
    } 
</style> 

HTML 난 정말 모르겠어요

<div class="parent"> 
    <div class="child">content</div> 
    <div class="child">>content</div> 
    <div class="child">>content</div> 
    <div class="child">>content</div> 
    <div class="child">>content</div> 
    <div class="child">>content</div> 
</div> 
+0

부모가 '친척'으로 만들었고 어린이는 '절대적으로'늘리지 않았기 때문에 그렇습니다. 일단 당신이 무언가를 "절대적"으로 만들면 더 이상 문서 흐름에 있지 않고 부모 div를 포함한 다른 요소들에 영향을주지 않습니다. – ScottS

+0

우선, 그것은 $ ("자식")이 아닌 $ ("자식")이되어야합니다. – Ana

+0

@An 그것은 .child입니다. – user618879

답변

0

이경우은 원했던 것입니다 만 작동하지만 조정할 수 있습니다.

관련 문제