使用CSS从右侧偏移背景图片 [英] Offset a background image from the right using CSS

查看:2104
本文介绍了使用CSS从右侧偏移背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将背景图片从其元素的右侧定位到一定数量的像素?

Is there a way to position a background image a certain number of pixels from the right of its element?

例如,要将某个数量的像素(例如10)从,这是我怎么做的:

For example, to position something a certain number of pixels (say, 10) from the left, this is how I'd do it:

#myElement {
    background-position: 10px 0;
}


推荐答案

/* to position the element 10px from the right */
background-position: right 10px top;

据我所知,IE8不支持。在最新的Chrome / Firefox中,它可以正常工作。

As far as I know this is not supported in IE8. In latest Chrome/Firefox it works fine.

请参阅

See Can I use for details on the supported browsers.

使用来源:http://tanalin.com/en/blog/2011/09/css3-background-position/

这篇关于使用CSS从右侧偏移背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆