I'm trying to create a bottom-up overlay effect for an image by hovering over it and displaying centered text, but I can't. I have read a lot, I have seen many tutorials, but I cannot apply it, since my image container is flex and I need to create this effect. I appreciate all help. I attach my html and css code
.containerFotos{
display: flex;
flex-wrap: wrap;
justify-content: space-around;
flex-direction: row;
overflow: hidden;
}
.containerFotos img{
margin-top: -150px;
width: 650px;
height: 400px;
padding: 100px;
z-index: 0;
}
.comida{
position: absolute;
left: 7.9%;
background-color: red;
width: 34.2%;
text-align: center;
top: 184%;
z-index: 3;
}
.comida:hover .overlay{
background-color: yellow;
/*height: 100px;*/
}
.overlay{
transition: height 10s;
background-color:rgba(43, 34, 68, 0.9);
}
.overlay:hover{
height: 20em;
}
<div class="containerFotos">
<img src="../img/descarga.jpg" />
<div class="comida">
<div class="overlay">
<p> prueba </p>
</div>
</div>
<img src="../img/MATUMBO-STEW-800x510.jpg"/>
<img src="../img/IMG_20170817_151825_mini-1024x576.jpg"/>
<img src="../img/150304102311-irio-cnn-super-169-1024x576.jpg"/>
<img src="../img/maharagwe-poa-pinterest-1024x538.jpg"/>
<img src="../img/tanzaniasafariprivatetours_wali-wa-nazi_riso-al-cocco-1024x629.jpg"/>
</div>
I hope this is what you need.
The structure of each card is this:
Where the image comes first and then the "overlay" Both the image and the overlay have
position:absolute;
to overlap at the time qualtop:0; left:0;
. I also want the div.comida
to haveoverflow: hidden;
: what sticks out is not visible.When the page is loaded
overlay
it has top:100% and is completely out of the container.comida
When passing with the mouse over the container
.comida
it.overlay
happens to havetop:0
, and so that the change is not abrupt I puttransition:top 1s;
Update
After several comments and after seeing a working example in codepen I have arrived at this version: