【问题标题】:chrome: border-radius on image with padding and backgroundchrome:带有填充和背景的图像上的边框半径
【发布时间】:2018-08-26 19:47:15
【问题描述】:

我想用渐变圆创建悬停效果。这段代码在 Firefox 中工作,以前在 chrome 中工作。现在 chrome 不会在填充图像上应用边框半径。请问,是否有可能让它再次在chrome中工作?感谢您的帮助。

.wrap {
  width: 400px;
  height: 400px;
}

a {
  display: block;
  padding: 20px 50px;
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

img {
  max-width: 100%;
  border-radius: 500px;
  padding: 0;
  transition: padding .4s;
  box-sizing: border-box;
}

a:hover>img {
  background: linear-gradient(to right, #d31249, #F60);
  padding: 15px;
}
<div class="wrap">
  <a href="#">
	<img src="https://image.freepik.com/free-icon/important-person_318-10744.jpg" alt="">
</a>
</div>

【问题讨论】:

    标签: html css google-chrome css-transitions


    【解决方案1】:

    您可以在a 元素上而不是img 上制作效果。我还添加了淡出效果,因此在鼠标移出时也可以看到渐变

    a.wrap {
      display: block;
      width: 300px;
      height: 300px;
      text-decoration: none;
      border-radius: 50%;
      padding: 0;
      transition: padding .4s, background-size 0s 0.4s;
      box-sizing: border-box;
      overflow: hidden;
      background: linear-gradient(to right, #d31249, #F60);
      background-size: 0 0;
    }
    
    img {
      max-width: 100%;
      border-radius: 50%;
      display: block;
    }
    
    a.wrap:hover {
      padding: 15px;
      transition: padding .4s, background 0s;
      background-size: 100% 100%;
    }
    <a href="#" class="wrap">
      <img src="https://image.freepik.com/free-icon/important-person_318-10744.jpg" alt="">
    </a>

    【讨论】:

      猜你喜欢
      • 2012-12-30
      • 1970-01-01
      • 1970-01-01
      • 2015-05-09
      • 2016-06-23
      • 2011-09-09
      • 1970-01-01
      • 2021-09-17
      • 2020-03-24
      相关资源
      最近更新 更多