缩放和透明颜色叠加鼠标悬停CSS

时间:2018-11-30 10:18:20

标签: html css css-transitions

我有这段代码将光标悬停在图像上。但是,我也确实希望在RGBHex中添加透明的颜色叠加层,如何将其添加到以下代码中?

.hover-zoom-in .fl-photo-content {
  overflow: hidden;
}
.hover-zoom-in .fl-photo-content .fl-photo-img {
  -webkit-transition: 0.3s ease-in-out;
          transition: 0.3s ease-in-out;
  will-change: transform;
}
.hover-zoom-in .fl-photo-content .fl-photo-img:hover {
  -webkit-transition: 0.3s ease-in-out;
          transition: 0.3s ease-in-out;
  -webkit-transform: scale(1.1);
          transform: scale(1.1);
}

提前谢谢!

1 个答案:

答案 0 :(得分:0)

我认为您正在寻找这样的东西:

.outer {
  display: inline-block;
}
.outer .image {
  position: relative;
  display: inline-block;
  transform: scale(1);
  transition: transform 0.5s ease 0s;
}
.outer .image img {
  width: 500px;
}
.outer .image::before {
  position: absolute;
  top: 0;
  left: 0;
  display: none;
  height: 100%;
  width: 100%;
  background-color: rgba(0, 0, 0, .6);
  content: '';
}
.outer .image:hover {
  transition: transform 0.5s ease 0s;
  transform: scale(1.1);
}
.outer .image:hover::before {
  display: block;
}
<div class="outer">
  <div class="image">
    <img src="https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/242ce817-97a3-48fe-9acd-b1bf97930b01/09-posterization-opt.jpg" alt="">
  </div>
</div>