HTML/CSS 将徽标定位到始终位于左上角,无论屏幕大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3488935/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML/CSS Positioning a logo to always be at the top left, no matter the screen size
提问by WillDonohoe
My question is a little hard to explain! Basically, I'm designing a website in HTML/CSS, and I need the logo to always be at the top left. On a windows machine, you can resize the browser from any side if I resize from the left hand side, my logo gets cut off.
我的问题有点难以解释!基本上,我正在用 HTML/CSS 设计一个网站,我需要徽标始终位于左上角。在 Windows 机器上,如果我从左侧调整大小,您可以从任何一侧调整浏览器的大小,我的徽标会被切断。
A good example of what I'm looking for is facebook, however you resize the screen the logo will stay locked in the top left corner.
我正在寻找的一个很好的例子是 facebook,但是您调整屏幕大小,徽标将保持锁定在左上角。
Am I having a blonde moment here, or is there a specific way of doing it?
我在这里度过了一个金发碧眼的时刻,还是有特定的方式来做到这一点?
回答by hollsk
Does this CSS not do the trick?
这个 CSS 不能解决问题吗?
position:absolute;
left:0;
top:0;
回答by Atul Dravid
position:fixed; top:0; left:0;