私は絶対divが相対divの底にくっついています。私がしたいのは、内側のdivをそのサイズが外側のdivよりも大きくなるたびにスクロール可能(上向き)にすることだけです。コンテンツをスクロール可能にするには、bottom:0に設定します。
しかし、それは起こりません。 divはスクロール可能にならない!ここではフィドルだ:https://jsfiddle.net/xggjmjqc/
HTML:
<div class="mobile1">
<div class="bottom1">
</div>
</div>
<br><br>
<!-- when inner gets bigger than outer: -->
<div class="mobile2">
<div class="bottom2">
</div>
</div>
CSS:
.mobile1{
height:400px;
width: 300px;
background-color: red;
position: relative
}
.bottom1{
height:100px;
width: 300px;
position: absolute;
bottom: 0;
background-color: blue;
}
/* when inner gets bigger than outer: */
.mobile2{
height:400px;
width: 300px;
background-color: red;
position: relative;
overflow-y: scroll;
}
.bottom2{
height:500px;
width: 300px;
position: absolute;
bottom: 0;
background-color: blue;
}
は、[この]のように内側の位置の相対 – Daniel
を作る(https://jsfiddle.net/ xggjmjqc/2 /)? –
は相対的なものではありません。なぜなら、外側(最初のケース)よりも小さくなった場合、底にくっついてしまうからです。内側のdivの内容は変数なので、場合によっては小さくなり、時には大きくなることもあります。 – jonhz