【发布时间】:2011-12-05 11:47:13
【问题描述】:
我有一个 500x500 像素的图像,它在我的网站上设置为背景图像(作为<body> 的背景图像)但我需要此图像位于网页的右下角。我怎样才能做到这一点? (用css方法更好)
谢谢。
【问题讨论】:
标签: css background
我有一个 500x500 像素的图像,它在我的网站上设置为背景图像(作为<body> 的背景图像)但我需要此图像位于网页的右下角。我怎样才能做到这一点? (用css方法更好)
谢谢。
【问题讨论】:
标签: css background
瞧:
body {
background-color: #000; /*Default bg, similar to the background's base color*/
background-image: url("bg.png");
background-position: right bottom; /*Positioning*/
background-repeat: no-repeat; /*Prevent showing multiple background images*/
}
背景属性可以组合在一起,形成一个背景属性。 另见:https://developer.mozilla.org/en/CSS/background-position
【讨论】:
jquery 正在将 bottom 更改为 0... :-/
background-attachment: fixed; 才能使其正常工作
background-attachment: fixed; 可以避免该问题。
更准确的定位:
background-position: bottom 5px right 7px;
【讨论】:
应该这样做:
<style>
body {
background:url(bg.jpg) fixed no-repeat bottom right;
}
</style>
【讨论】:
您是否尝试过类似的方法:
body {background: url('[url to your image]') no-repeat right bottom;}
【讨论】: