How to position background image in bottom right c

2019-01-17 09:34发布

I have a 500x500 px image which is set as a background image on my website (as background-image of <body>) But I need this image to be located in a bottom right corner of the webpage. How can I achieve this? (better with css method)

Thank You.

4条回答
男人必须洒脱
2楼-- · 2019-01-17 09:53

This should do it:

<style>
body {
    background:url(bg.jpg) fixed no-repeat bottom right;
}
</style>

http://www.w3schools.com/cssref/pr_background-position.asp

查看更多
干净又极端
3楼-- · 2019-01-17 10:02

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*/
}

The background properties can be combined together, in one background property. See also: https://developer.mozilla.org/en/CSS/background-position

查看更多
淡お忘
4楼-- · 2019-01-17 10:03

for more exactly positioning:

      background-position: bottom 5px right 7px;
查看更多
孤傲高冷的网名
5楼-- · 2019-01-17 10:11

Did you try something like:

body {background: url('[url to your image]') no-repeat right bottom;}
查看更多
登录 后发表回答