1
div의 격자가 표시되며 각 div의 내용은 사용자의 작업에 따라 다를 수 있습니다. 새 콘텐츠가 div에 추가되면 업데이트 된 div가 아래 div와 겹칩니다.div의 자동 세트 높이
Freewall jquery 플러그인을 사용해 보았지만 어떻게 든 높이를 동적으로 설정할 수 없었습니다.
샘플 코드를 아래 링크를 참조하십시오 http://jsfiddle.net/Pj6e6/HTML
<div id="holder">
<div id="one" class="item">Item 1</div>
<div id="two" class="item">Item 2</div>
<div id="three" class="item">Item 3</div>
<div id="four" class="item">Item 4</div>
<div id="five" class="item">Item 5</div>
</div>
<div id="clearer"></div>
<br/>
<br/>
<input type="button" value="Add to Item 1" id="add_one" />
<input type="button" value="Add to Item 2" id="add_two" />
<input type="button" value="Add to Item 3" id="add_three" />
CSS
/* The width of container DIV */
#holder {
width:400px;
}
/* Style for each floated item */
.item {
/* Give the distance for floated items */
margin:2px 2px 2px 2px;
float:left;
/* Width and height for each item */
width:100px;
height:100px;
/* Text align and background color */
text-align:center;
background-color:#cdc;
}
/* Clear the "float" style */
#clearer {
clear:both;
}
jQuery를
01 23,516,$("#add_one").click(function() {
$("#one").html('Item 1<br/ >Item 1<br/ >Item 1<br/ >Item 1<br/ >Item 1<br/ >Item 1<br/ >Item 1<br/ >Item 1<br/ >Item 1<br/ >Item 1<br/ >Item 1<br/ >Item 1<br/ >Item 1<br/ >');
});
$("#add_two").click(function() {
$("#two").html('Item 2<br/ >Item 2<br/ >Item 2<br/ >Item 2<br/ >Item 2<br/ >Item 2<br/ >Item 2<br/ >Item 2<br/ >Item 2<br/ >Item 2<br/ >Item 2<br/ >Item 2<br/ >Item 2<br/ >');
});
$("#add_three").click(function() {
$("#three").html('Item 3<br/ >Item 3<br/ >Item 3<br/ >Item 3<br/ >Item 3<br/ >Item 3<br/ >Item 3<br/ >Item 3<br/ >Item 3<br/ >Item 3<br/ >Item 3<br/ >Item 3<br/ >Item 3<br/ >');
});
존
당신이 고정 된 높이의'분 - height'instead를 시도? – Mathias
하나의 셀이 점점 커지면 전체 행이 커지기를 기대합니까? – malkassem
@Mathias 나는 당신의 해결책을 좋아하지만, 제 경우에는 아래 div가 아래로 이동하는 것이 아니라 옆으로 움직이고 있습니다. – johnk1