I have created a small mockup of the issue here: https://codepen.io/rctneil/pen/PoBgZEe?editors=1100
What I wish to achieve is effectively to remove the space above and below the logo inside the dotted red outline.
I want to keep the logo in exactly the same place as it is (horizontally centered and vertically centered on the photo's bottom edge), but remove the space above and below. This should reduce the overall height of the card.
I do not know the dimensions nor aspect ratio of the logos ahead of time.
Any ideas?
* {
box-sizing: border-box;
}
p {
margin: 0;
}
html {
height: 100%;
display: grid;
place-items: center;
}
.card {
position: relative;
width: 200px;
border: 2px solid black;
}
.photo {
display: block;
width: 100%;
aspect-ratio: 1/1;
object-fit: cover;
}
.logo {
display: flex;
justify-content: center;
align-items: center;
position: relative;
margin-top: -25%;
padding: 25%;
min-width: 100%;
pointer-events: none;
outline: 2px dotted red;
}
.logo img {
position: absolute;
display: block;
max-width: 50%;
max-height: 75%;
margin-top: 0;
padding: 0.2rem;
border-radius: 0.25rem;
box-shadow: 0px 0px 3px 1px rgba(0, 0, 0, .25);
background-color: #fff;
pointer-events: all;
}
.meta {
display: flex;
flex-direction: column;
gap: 0.5rem;
padding: 1rem;
text-align: center;
}
<div class="card">
<img class="photo" src="https://farm66.staticflickr.com/65535/48808899778_bb1d4d1272_b.jpg" />
<div class="logo">
<img src="https://neiltongesite.s3.us-west-001.backblazeb2.com/coasters/logos/colossus-thorpe-park-resort-chertsey.png" />
</div>
<div class="meta">
<p>Name here</p>
<p>Sub title here</p>
</div>
</div>