无论浏览器尺寸如何,固定 div
我有一个带有一些装饰的小图像,我需要将其粘贴到页面的右上角。但无论我使用了多少种不同类型的代码,我都无法做到正确。
这有点像本页顶部的“欢迎来到专业问答......”,无论我向下滚动多远,它都会保留在那里。
我只需要使用包含图像的图像来执行此操作,即使我调整大小,该图像也会粘在浏览器的右边距上。
您可以查看网站 http://dawtano.com/pp/ 并查看当前位于页面中间..
I have a little image, with some decoration, that I need to stick to the top-right corner of my page. But no matter how many different types of code I've used, I can't get it right.
It's sort of like the "Welcome to Q&A for professional.." on top of this page, it stays there no matter how far down I scroll.
I just need to do this with a containing an image, that sticks to the right-margin of the browser, even if i resize.
You can look at the website http://dawtano.com/pp/ and see the image, that's currently in the middle of the page..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您只需将背景的重力指定为
右上角
即可。You just need to specify the gravity of the background to
right top
.将
{background-position: right top;}
应用于背景图像。Apply
{background-position: right top;}
to the background image.如果我理解你的问题是正确的:
使用位置:固定和顶部,就在你的CSS中
哦,这是背景图像......
使用背景位置:右上;
If i unsterstand your question correct:
Use position: fixed and top, right in your css
Oh, it´s a background-image...
Use background-position:right top;
我假设您指的是#deco div。如果是这样,根据您当前的示例,这应该有效:
I assume you mean for the #deco div. If so, based on your current example, this should work: