私は持っています
<div id="div1">
any not fixed text
but this div has scrollbar
<div id="div2">
this div is fixed (without scrollbar)
</div>
</div>
div2に固定する必要がありますがdiv1、メインブラウザのスクロールバーに固定する必要はありません。「div2をdiv1に貼り付ける」のようなものです。
div1スクロールバーがあるので、修正する必要がありますdiv2。
私がこれを作った場合:
#div1 {
position: absolute;
}
#div1 #div2 {
position: fixed;
}
修正さdiv1れ、ブラウザのウィンドウも修正されますが、必要なのは。だけdiv1です。
テストする例:
<html>
<head>
<style type="text/css">
#div1 {
border: 1px solid gray;
position: absolute;
height: 200px;
width: 400px;
overflow-y: scroll;
}
#div1 #div2 {
position: fixed;
margin-left: 300px;
}
</style>
</head>
<body>
<br><br><br>
<div id="div1">
<div id="div2">fixed text</div>
<div style="height: 400px;"></div>
</div>
<div style="height: 1400px;"></div>
</body>
</html>
Q1:修正div2方法div
Q2:この場合float: right div2、右側への移動方法div1(たとえば〜margin-left: 350px;)
ありがとうございました。