4 개의 내부 div가있는 4 개의 컨테이너가 있고 자동 높이로 왼쪽에 떠있었습니다.
<div class="box">
<div class="head">
Heading text
</div>
<div class="image">
Image
</div>
<div class="text">
Integer posuere erat a ante venenatis dapibus posuere velit aliquet.
</div>
<div class="link"><a href="#">Link text</a></div>
.box{
width: 150px;
float: left;
}
jsFiddle 완료 : http://jsfiddle.net/H8w32/
내부 div의 높이를 네 컨테이너 모두에서 동일하게 만들기 위해 플로팅 레이아웃을 변경하고 대신 display : table을 사용했습니다.
<div class="table">
<div class="row head">
<div class="cell">Heading text</div>
<div class="cell">Here is a lot longer heading text to examplify</div>
<div class="cell">Heading text</div>
<div class="cell">Heading text</div>
</div>
<div class="row image">
<div class="cell">Image</div>
<div class="cell">Image</div>
<div class="cell">Image</div>
<div class="cell">Image</div>
</div>
<div class="row text">
<div class="cell">Integer posuere erat a ante venenatis dapibus posuere velit aliquet.</div>
<div class="cell">Integer posuere erat a ante venenatis dapibus posuere velit aliquet.</div>
<div class="cell">Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Integer posuere erat a ante. Dapibus posuere velit aliquet.</div>
<div class="cell">Integer posuere erat a ante venenatis dapibus posuere velit aliquet.</div>
</div>
<div class="row link">
<div class="cell"><a href="#">Link text</a></div>
<div class="cell"><a href="#">Link text</a></div>
<div class="cell"><a href="#">Link text</a></div>
<div class="cell"><a href="#">Link text</a></div>
</div>
</div>
-
.table{
display: table;
}
.row{
display: table-row;
}
.cell{
display: table-cell;
width: 150px;
}
이것은 내가 원했던 것과 똑같아 보입니다. 하지만 이제 저는 float를 사용하여 특전을 잃었습니다. 특히 컨테이너를 더 추가하고 자동으로 다음 "행"으로 푸시되거나 뷰포트가 너무 작아서 새 행으로 푸시되는 기능을 잃었습니다. display : table 레이아웃에 컨테이너를 더 추가하면 컨테이너가 동일한 "행"에 추가됩니다.
이것이 해결할 수 있습니까? display : table (제목 div 및 텍스트 div의 동일한 높이) 및 float : left의 동작을 원합니다.
현재 자바 스크립트를 사용하여 높이를 설정하지 않으면 불가능합니다. 이 문제에 대한 실제 CSS 전용 솔루션 인 CSS 유연한 상자의 사양을 살펴볼 수 있습니다.
https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes
flexbox의 채택은 아직 초기 단계에 있지만 대부분 최신 브라우저를 대상으로하는 최첨단 앱을 구축하는 경우에는이를 벗어날 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다