I experienced that the parent div .img-wrapper
that has no height given by me, so that would mean it's auto by default it is 7px larger than its child the img
when I was expecting that it will take up the height of the child. Why does that happen?
The html:
<li class="hover:cursor-none" v-for="teammember in projectTeamData || projectTeamDataClientView" :key="teammember.id" >
<div class="w-full px-10 md:px-2 py-10 teammember_big text-left">
<div class="img-wrapper relative hover:cursor-pointer">
<img class="w-full" :src="teammember.picture">
<div class="img-overlay"></div>
<div class="work-overlay"><div class="work-description"><div class="work-title" v-text="teammember.title"></div><div class="work-phone"><span>M:</span> <a :href="'tel:' + teammember.phone_number"><span v-text="teammember.phone_number"></span></a></div><div class="work-email"><span>E:</span> <a :href="'mailto:' + teammember.email"><span v-text="teammember.email"></span></a></div></div></div>
<div class="button-holder"><a class="button">BIO & DETAILS</a>
</div>
</div>
<p class="text-black text-center name" v-text="teammember.name"></p>
</div>
</li>
The CSS:
Since I want the .image-overlay
as big as the ´img´ I had to set bottom: 7px;
for it in order to achieve that.
.img-overlay {
background-color: transparent;
position: absolute;
top: 0;
right: 0;
bottom: 7px;
left: 0;
width: 100%;
transition: background-color 0.25s ease-in-out;
}
This is what I have on the img
:
img {
width: 100%; // from the tailwind
max-width: 100%;
height: auto;
}
and finally the .img-wrapper
is set to relative
as you can see
with tailwind.