I have some staff tiles that have their name and title over the image. On mouse hover I would like the image to slightly zoom and the text to slide off the image. I have been able to do all the animations, however I can't get the text to hide when it slides off the image.
I have tried all kinds of variations of overflow: hidden
and messed with white-space
and text-overflow
but no luck.
I have created a CodePen here: https://codepen.io/iisrael/pen/EBjmPW
Here is the HTML
<div class="speaker-tile-grid">
<div class="speaker-tile">
<img src="https://cdn.pixabay.com/photo/2016/06/09/20/38/woman-1446557_960_720.jpg" width="300px" height="300px">
<h3>Person #1</h3>
<h4>They do stuff</h4>
</div>
</div>
Here is the CSS:
.speaker-tile-grid {
display: grid;
grid-template-columns: repeat(auto-fit,minmax(200px, 300px));
grid-template-rows: repeat(auto-fit,minmax(200px, 300px));
grid-gap: 1em;
margin: 0;
}
.speaker-tile {
overflow: hidden!important;
}
.speaker-tile img {
transition: 750ms;
}
.speaker-tile:hover img {
transform: scale(1.05);
}
.speaker-tile h3 {
position: absolute;
bottom: 45px;
background-color: #ff6600;
color: white;
padding: 5px 10px 10px 10px;
transition: 750ms;
}
.speaker-tile:hover h3 {
transform: translateX(-100%);
}
.speaker-tile h4 {
position: absolute;
bottom: 25px;
background-color: #313131;
color: white;
padding: 4px 10px;
transition: 750ms;
}
.speaker-tile:hover h4 {
transform: translateX(-100%);
}
I need to know how to make the text hide when it's off the image. text-overflow: Clip
or overflow: hidden
or something else since those didn't work for me. Any help is greatly appreciated.