我已经被设置为我的网站上的背景图像(作为<body>
背景图像)500×500一像素的图片,但我需要这个图像位于网页的右下角。我怎样才能做到这一点?如何在右下角放置背景图片? (CSS)
谢谢(用CSS方法更好)。
我已经被设置为我的网站上的背景图像(作为<body>
背景图像)500×500一像素的图片,但我需要这个图像位于网页的右下角。我怎样才能做到这一点?如何在右下角放置背景图片? (CSS)
谢谢(用CSS方法更好)。
Voilla:
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
你尝试类似:
body {background: url('[url to your image]') no-repeat right bottom;}
这应做到:
<style>
body {
background:url(bg.jpg) fixed no-repeat bottom right;
}
</style>
为更精确的定位:
background-position: bottom 5px right 7px;
做得好提供范例上的背景图像的对准相对于通过像素“停靠点”微调 –
Thnx,今天我帮了我很多安静))) – Ilja
不工作,当背景图像高于屏幕高度... – Legionar
@Legionar适用于我,在Chrome 43和Firefox 38中很好。 –