我尝试在具有的容器内显示一个简单的图像border-radius: 5px;
。但是角落似乎有一个细边框的轮廓(您需要仔细看一下下图)。我如何避免这些拐角边界?
.cover {
margin: 1em;
padding: 1em;
}
.image-wrapper {
height: 15em;
width: 15em;
overflow: hidden;
background-color: black;
border-radius: 15px;
}
img {
height: 100%;
width: auto;
}
<div class="cover">
<div class="image-wrapper">
<img
src="https://images.pexels.com/photos/316466/pexels-photo-316466.jpeg"
/>
</div>
</div>
是的,如果我删除,它会消失background-color: black;
。但是,我需要保留,background-color
并且还需要img { height: 100%; width: auto; }
保持宽高比,并在图像尺寸太薄或太宽等情况下照顾场景。
搜索其他类似的问题,我只能找到Safari的问题/答案。我正在使用Brave浏览器。
这种破解似乎有效。
background-clip: content-box;
padding: 1px;
background-clip: content-box;
具有比浏览器更好的支持 -webkit-mask
.cover {
margin: 1em;
padding: 1em;
}
.image-wrapper {
height: 15em;
width: 15em;
overflow: hidden;
background-color: black;
border-radius: 15px;
background-clip: content-box;
padding: 1px;
}
img {
height: 100%;
width: auto;
}
<div class="cover">
<div class="image-wrapper">
<img src="https://images.pexels.com/photos/316466/pexels-photo-316466.jpeg" alt="hello" />
</div>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句