は、私のホームページの簡易版です。親の幅内にある固定div?ここ
<div class="main">
<div class="content"> all the content of my website </div>
<div class="nav"> fixed on the screen and always visible </div>
</div>
そしてここでは、対応するCSSです:
.main {
max-width: 500px;
height: 2000px;
margin: auto;
background-color: grey;
}
.nav {
width: 100px;
height: 100px;
background-color: blue;
position:fixed;
right: 0; /* that's the issue */
}
私はそれが親(親の右端に触れるだ内に収まるように固定要素が欲しいです)。しかし、今は画面の右端に触れています。
これを修正する方法はありますか?ありがとう!
だけで位置の右の代わりにフロートを使うのか? –
しかし、私はdivを固定したいので、スクロールしても常に画面に表示されます。 – Thomas
これは、絶対的な位置決めのために少しのJavaScriptを使う必要があります。 – Pete