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?
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)
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.
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;
}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With