div .icon의 위치를 설정할 때 상위 div의 위치를 선언해야합니다. 요소의 위치 값을 설정할 때 위치가 선언 된 바로 옆에있는 상위 div를 기준으로 위치를 계산합니다. .section에 위치 세트가없는 경우 .icon은 .container에 상대적인 위치를 계산합니다 (컨테이너에 위치 세트가있는 경우).
<div class="container">
<div class="section">
<div class="text">
<b>Case 1:</b>
Gray has lower height than orange
</div>
<div class="icon">
</div>
</div>
<div class="section">
<div class="text tall">
<b>Case 2:</b>
Gray has bigger height than orange
</div>
<div class="icon">
</div>
</div>
</div>
body {
background-color: #333333;
margin: 0;
}
.container {
margin: 0 auto;
width: 80%;
}
.section {
position:relative;
background-color: #FFFFFF;
min-height: 200px;
margin-bottom: 200px;
width: 100%;
}
.text {
background-color: #999999;
height: 100px;
width: 100%;
text-align: right;
position:absolute;
left:0;
bottom:0;
}
.tall {
height: 300px;
}
.icon {
width: 250px;
height: 250px;
background-color: #FF9933;
border: #000000 2px dashed;
z-index: 1;
position: absolute;
right:0;
bottom:0;
}
고맙습니다. 작동합니다. 단,'.text'에서'padding-right : 270px; '를 지우지 않았다. 왜냐하면 나는 그 conent들을 중심에 둘 필요가 있기 때문이다. – Taosique
@Taosique 좋아, 그게 네가 원하는대로 자네, 그리고 당신은 환영합니다) –