위에 블록을 중심이되는 HTML 내가 가진 :수직으로 다른 블록의 하단 라인
이것은 내가 뭘하려 :
<div class="image">Image</div>
<div class="legend">
Legend<br/>
width variable height<br/>
the middle of the legend need to be exactly on the bottom of the image, regardless of the height of the legend and image
</div>
<div class="following">The following text should follow immediatly the legend,regardless of the height of the legend or the image</div>
이 내가 원하는 결과입니다
.image {
height:100px;
background-color:red;
}
.legend {
transform:translateY(-50%);
background-color:blue;
width:300px;
margin:0 auto
}
.following {
background-color:yellow;
margin-top:-45px;
}
문제는 다음과 같습니다. 전설과 다음 텍스트 사이에이 여백을 두지 않아도됩니다.
The whole attempt codepen is here
질문 : 모든 용액 JS 않고도 원하는 결과를 얻을?
는 (기록을 위해 : this is a solution with JS)
가 아니, 어느 요소의 높이를 모르는 데 도움이 – sylvain
그리고 정확히 50 % 높이가이다의 "가서"해당 요소를해야합니까? – Dekel
예 정확히 중간에 – sylvain