Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Want to position the background image in the middle

Hello on my login page I have a background image. Currently the image is centered but not centered the way I want it. I want it so the image is always centered in the middle of the screen. Curently, my image is centered but is positioned at the top of the page. The image need to be positioned in the middle of the screen, and kept centered.

login.html
 <body style="background-image: url({{MEDIA_URL}}/admin_media/img/admin/bigstock_Photo_Showing_Financial_Growth_1339836.jpg); background-position: 50% 50%; background-repeat:no-repeat;">
like image 708
Shehzad009 Avatar asked Oct 03 '11 10:10

Shehzad009


People also ask

How do I take the background of a picture in the middle?

You need to specify the position of the image through the "center" value of the background shorthand property. Set the width of your image to "100%". In this example, we also specify the height and background-size of our image.

How do I put a background image in the middle of a div?

To center an image, we have to set the value of margin-left and margin-right to auto and make it a block element by using the display: block; property. If the image is in the div element, then we can use the text-align: center; property for aligning the image to center in the div.

Which position adjust the background image in the center of the desktop?

You can use a combination of position keywords: center , top , bottom , left and right . background-position: center center; The background image will be positioned in the center of the element.

What is background image position?

The background-position property sets the starting position of a background image. Tip: By default, a background-image is placed at the top-left corner of an element, and repeated both vertically and horizontally.


1 Answers

may be you have write like this :

background-position: center center;

EDIT:

may be there problem with the body because it not takes screen entire height so if you want an image show in the center of the screen then write

html,body{height:100%;}
body{
    background:url(http://www.poster.net/van-gogh-vincent/van-gogh-vincent-sternennacht-2601013.jpg) no-repeat fixed center center;
}

check the example http://jsfiddle.net/sandeep/m2fZs/2/

like image 74
sandeep Avatar answered Oct 19 '22 02:10

sandeep