gpt4 book ai didi

html - Chrome : border-radius on image with padding and background

转载 作者:行者123 更新时间:2023-11-27 23:02:11 25 4
gpt4 key购买 nike

我想用渐变圆创建悬停效果。此代码在 firefox 中工作,以前在 chrome 中工作。现在 chrome 不会在填充图像上应用 border-radius。拜托,是否可以让它再次在 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>

最佳答案

您可以在 a 元素而不是 img 上产生效果。我还添加了淡出效果,所以渐变在 mouseout 上也可见

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>

关于html - Chrome : border-radius on image with padding and background,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52025631/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com