是否可以在保持“右上角”的同时更改背景位置?
我有一个背景位置为“右上角”的对象
,我想将此背景位置向上移动 10px(悬停时),但是一旦我更改值,新值就会从 0,0 插入点(左上),但我想要(右上)
有没有 100% CSS 解决方案?
I have an object that have a background with background-position "top right"
I want to move this background-position up by 10px (on hover), but as soon I change the values, the new value is inserted from the 0,0 point (top left) but I want (top right)
Is there any 100% CSS solution to this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这就是您想要的:
给它一个
background-position:100% 0
将其设置为右上角。然后从悬停时的高度减去10px
。示例: http://jsfiddle.net/jasongennaro/Teyfj/
< em>高度、宽度和边框仅作为示例
I think this is what you want:
Giving it a
background-position:100% 0
sets it to the top right corner. Then minus10px
from the height on hover.Example: http://jsfiddle.net/jasongennaro/Teyfj/
Height, width, and border are for example only
如果你想在悬停时更改特定元素的背景图像:
所以你可以制作第二个图像,距离顶部 10px,这应该可以工作,我想使用
body
而不是#my_element
。If you want to change the background image of a particular element on hover:
So you could make a second image with 10px off the top and this should work, I guess with
body
instead of#my_element
.