div .iconの位置を設定するときに、その親divの位置を宣言する必要があります。要素の位置値を設定するときは、位置が宣言されている次の直前の親divを基準にしてその位置を計算します。 .sectionに位置が設定されていない場合、.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; 'を削除しました。なぜなら、私はそのconcentを中心にする必要があるからです。 – Taosique
@Taosiqueオクラホマ、それはあなたがそれを望むようにあなたまで、あなたは歓迎です) –