gpt4 book ai didi

css - 当父元素和子元素都有边框半径时,有没有办法防止父元素的背景出现在边缘?

转载 作者:太空宇宙 更新时间:2023-11-04 10:44:49 34 4
gpt4 key购买 nike

假设我们在另一个 div 中有一个 div;父子 div 具有相同的 border-radius,子元素的宽度和高度是父元素的 100%。如果 parent 的背景与 child 的背景不同,则在 child 的圆 Angular 周围会看到一条细线:

这是它的样子:

enter image description here

这是 CodePen 上的一个例子:http://codepen.io/azangru/pen/MKdQmG

以及代码本身:

HTML:

<div class="dark-bg">
<div class="outer">
<div class="middle">
<div class="inner">
</div>
</div>
</div>
</div>

CSS:

html, body {
height: 100%;
margin: 0;
padding: 0;
}

.dark-bg {
height: 100%;
width: 100%;
padding-top: 10px;
background: black;
}

.outer {
width: 200px;
height: 200px;
margin: auto;
background: white;
border-radius: 10px;
}

.middle {
width: 100%;
height: 100%;
background: yellow;
border-radius: 10px;
}

.inner {
width: 100%;
height: 100%;
background: black;
border-radius: 10px;
}

有没有办法防止 parent 的背景从 child 身后出现(我的意思是不完全移除 parent 的背景)?

最佳答案

关于css - 当父元素和子元素都有边框半径时,有没有办法防止父元素的背景出现在边缘?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35505746/

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