While passing the mouse over the name
class does not appear
.img
{
width: 100%;
height: 100%;
object-fit: cover;
filter: grayscale(100%);
}
.img:hover
{
filter: grayscale(0%);
}
.img:hover .name
{
display: flex;
}
.container
{
width: 300px;
height: 200px;
}
.name
{
position: fixed;
width: 300px;
height: 30px;
background: rgba(0, 0, 0, .5);
justify-content: center;
display: none;
font-size: 22px;
color: #fff;
z-index: 999;
}
<div class="container">
<div class="name">
Barney
</div>
<img class="img" src="http://www.mamamagic.co.za/wp-content/uploads/2016/01/barney.jpg">
</div>