是否可以在绘制的位置(这是标准的“static
/relative
”位置)制作一个 div fixed
?
所以我希望 div .one
、.three
和 .four
固定在最初绘制的位置。这样它就不会滚动。 https://jsfiddle.net/sor8hntk/2/
最佳答案
是的! https://jsfiddle.net/sor8hntk/7/
body {
margin-top:40px;
}
.one {
float:left;
background-color:green;
width:33%;
height:50px;
position: fixed;
}
.two {
float:left;
background-color:red;
width:33%;
height:500px;
left: 33%;
position: absolute;
}
.three {
float:left;
background-color:blue;
width:33%;
height:50px;
position: fixed;
left: 66%;
}
.four {
width:33%;
background-color:purple;
height:10px;
position: fixed;
}
.five {
width:100%;
background-color:pink;
margin-top: 10px;
}
.six {
width:100%;
height:10px;
background-color:yellow;
}
关于javascript - 将 div 设置为固定在相对位置上的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43168938/