Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make an image start at the bottom of it's container?

I have a tall image inside a short container with overflow: hidden;. The bottom of the image is cut off. How do I make the top get cut off instead of the bottom?

dramatized

like image 621
Christian Chapman Avatar asked Aug 22 '11 23:08

Christian Chapman


People also ask

How do you position something at the bottom of a container in CSS?

To put an element at the bottom of its container with CSS, you need to use the following properties and values: position: relative; (parent) position: absolute; (child) bottom: 0; (child)

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.


2 Answers

If your image is just the background-image of the container, do this way:

#container {
    background: url(your-image.jpg) no-repeat bottom left;
}

Otherwise, position the img element to the bottom of the container, like @Joseph suggested:

#container {
    position:relative;
}

#container img {
    position: absolute;
    bottom: 0px;
}
like image 136
Erick Petrucelli Avatar answered Nov 05 '22 03:11

Erick Petrucelli


give the container the following css:

position:relative;

and the image the following css:

position:absolute;
bottom:0px;

P.S.
Very nice (and clear) illustrations btw

like image 40
Joseph Marikle Avatar answered Nov 05 '22 04:11

Joseph Marikle