且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

需要将图像固定到页面上的特定位置

更新时间:2023-10-09 14:42:52

如果使用位置:固定,该元素相对于窗口定位,因此即使滚动,该元素也不会移动。

If you use position:fixed, the element is positioned relatively to the window, so even if you scroll, the element doesn't move.

如果需要要滚动时要移动,请使用 position:absolute

If you want it to move when you scroll, use position:absolute.

但是由于您的布局,您有2个选择:

But because of your layout, you have 2 options:


  • 将图像放入 #box

  • 删除以下代码:

html{
    overflow:hidden;
    height: 100%;
    max-height: 100%;
}
body {
    height: 100%;
    max-height: 100%;
    width: 100%;
}
#box {
    height: 100%;
    max-height: 100%;
    overflow: auto;
    width: 100%;
}