问题描述
因此,我查看了该网站,发现与我要查找的内容相近但又不完全相同的问题.
So I've checked the site and I've seen questions close to what I am looking for but not exactly the same.
我想弄清楚如何定位一个元素,以便在滚动(向上/向下)时位置是固定的,但是当浏览器调整大小(向左/向右)时,位置是绝对的或相对的.
I am trying to figure out how to position an element so that when scrolled (up / down) the position is fixed, but when the browser is resize (left / right) the position is absolute or relative.
基本上我想在浏览器窗口左上角放置一个元素(例如),并让它在滚动/窗口调整大小时停留在那里.
Essentially I want to place an element 10% (for example) from the top left of the browser window and have it stay there on scroll /window resize.
推荐答案
如果你想要的东西总是固定在某个位置,即使浏览器滚动/调整大小,你可以为你的 css 试试这个
if what you want is always fixed in some position even if the browser is scrolled / resized, you may try this for your css
.fixedelement {
position: fixed;
top: 10%;
left: 10%;
width: 80%; /*my example*/
height: 10%;
}
这篇关于固定与绝对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!