html - 使用 CSS 实现图像悬停效果的有机形状

标签 html css

我有一个关于有机形状图像的任务,我希望悬停时的背景颜色像那个特定的有机形状图像。我没有在具有背景颜色的图像上获得悬停效果。我已经尝试了很多,但我做错的地方并没有出现。任何人都可以指出正确的方向来解决我的问题吗? 提前致谢...

.at-organic-shape {
  position: relative;
  height: 500px;
  width: 500px;
}
.at-organic-shape figure img:hover {
  background-color: #6495ED;
  border-radius: 35% 80% 65% 70%/50% 65% 70% 85%;
  transition: all 0.5s linear;
}
<div class="at-organic-shape">
  <figure>
    <img src="https://image.ibb.co/nHDcuq/1-F19-F06-C-0-F3-E-4055-B0-E5-1-D73728-A7730.png" class="img1"/>
  </figure>
</div>

最佳答案

你可以尝试使用一个伪元素和一个mix-blend-mode来隐藏颜色溢出:

.at-organic-shape {
  position: relative;
  height: 500px;
  width: 500px;
}
.at-organic-shape figure {
  position:relative;
  background:#fff;
}
.at-organic-shape figure:after {
  content:"";
  position:absolute;
  top:0;
  left:0;
  right:0;
  bottom:0;
  background:transparent;
  mix-blend-mode: color;
  transition: all 0.5s linear;
}
.at-organic-shape figure:hover::after {
  background:#6495ED;
}
<div class="at-organic-shape">
  <figure>
    <img src="https://image.ibb.co/nHDcuq/1-F19-F06-C-0-F3-E-4055-B0-E5-1-D73728-A7730.png" class="img1"/>
  </figure>
</div>

关于html - 使用 CSS 实现图像悬停效果的有机形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53445622/

相关文章:

javascript - 如何更改谷歌地图中选择的特定状态的颜色

javascript - 无法在 Safari 中设置焦点

css - 删除 3D 按下​​效果 Internet Explorer 按钮

java - 在JavaFx Gui中添加图片

javascript - 为什么在我尝试打印网页时,广告内容没有在每个打印页面中重复出现?

javascript - 带有光标跟随器的 Canvas

javascript - 输入数据摘要

javascript - HTML5音频-所有网页的音乐相同

css - 标题 CSS 未在整个网站上统一显示

html - 将 div 置于背景图像之上