I’m trying to align the content of two images (in this case aligning the placeholder 150×150 label). The second image needs to be lower than the first.
div {
background-color: purple;
display: flex;
}
img {
display: block;
border-radius: 30px;
align-self: start;
}
#img2 {
margin-top: 50px;
object-position: 0px -50px;
}
<div>
<img src='https://via.placeholder.com/150' />
<img src='https://via.placeholder.com/150' id='img2' />
</div>
I shift the second image down 50px and raise its contents by putting the objectposition up 50px, but it cuts off the bottom side of the image, it happens even when i use regular taller images
It doesnt seem to be an overflow issue. How can i fix this?
3
Answers
I fixed it by taking a look at Aurélien's answer. Also the main issue was that I needed a container for each image and to put margin-top on a container instead of the actual image
What do you mean by "and raise its contents" ? The content of the image ???
Anyways, maybe this is what you are trying to do:
Your code works perfectly, as long as the images are the same size as the divs, the result will always be this one.
To get the result I think you’re trying to get, your images need to be larger than the divs, and the divs need to have a overflow: hidden