Could you tell me please, is there a way to do the following 2 features at the same time?
- The image should have a semi-transparent background
- The image should be scaled when on hover
Currently, I've got only one of these: either scaling without semi-transparent background or image and semi-transparent background without scaling.
.item {
border: 1px solid red;
width: 200px;
height: 150px;
overflow: hidden;
position: relative;
}
img {
width: 200px;
height: 150px;
transition: all 0.3s;
}
img:hover {
transform: scale(1.1);
}
.blackout {
background: rgba(0, 0, 0, 0.5);
z-index: 1000;
}
.hover {
position: absolute;
top: 0;
height: 100%;
width: inherit;
}
<div class="item">
<img src="https://img3.goodfon.com/original/4500x3600/4/cf/britanskaya-korotkosherstnaya-5636.jpg" alt="cat">
<div class="hover blackout"></div>
</div>
<div class="item blackout">
<img class="blackout" src="https://img3.goodfon.com/original/4500x3600/4/cf/britanskaya-korotkosherstnaya-5636.jpg" alt="cat">
</div>
<div class="item blackout">
<img src="" alt="cat">
</div>