Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I stick an image to the bottom of the visible screen, and be centered?

Tags:

css

center

sticky

I have a website, and I need to have an image centered at the bottom of the visible page. So in any screen size, the image will still be at the bottom, and centered.

like image 519
Shawn Avatar asked Apr 03 '10 10:04

Shawn


People also ask

How do I keep an image centered?

Step 1: Wrap the image in a div element. Step 2: Set the display property to "flex," which tells the browser that the div is the parent container and the image is a flex item. Step 3: Set the justify-content property to "center." Step 4: Set the width of the image to a fixed length value.

How do I fix the position of a picture?

To position an image relative to a page, select the image and from the menu bar below it, select “Fix position on page”. To open the “Image options” sidebar, select the overflow menu (three dot), followed by “All image options”. To learn more about formatting images in Google Docs, see this article in our Help Center.

How do I make elements sit at the bottom of the page?

If position: absolute; or position: fixed; - the bottom property sets the bottom edge of an element to a unit above/below the bottom edge of its nearest positioned ancestor. If position: relative; - the bottom property makes the element's bottom edge to move above/below its normal position.


1 Answers

You should put it into a div and then, imagining your image is 500px wide:

div.className{
position:absolute;
margin-left: -250px; /* very important for the image to be centered */
left:50%;
bottom:0px;
}
like image 108
fmsf Avatar answered Oct 08 '22 23:10

fmsf