html - CSS3 border-radius 裁剪问题

标签 html css

我有一个 border-radius 设置为某个值(比如 10px)的 div,以及一个嵌套的 div,它是其父元素的完整宽度和高度。

<!-- ... -->
<style type="text/css">
div.parent {
    display: block;
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 10px;
    background: #0000ff;
    overflow: hidden;
}
div.inner {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    background: #ff0000;
}
</style>
<!-- ... -->
<div class="parent">
    <div class="inner"></div>
</div>
<!-- ... -->

我注意到尽管溢出被设置为隐藏,但父项并未将子项夹在圆 Angular 周围。另一个 stackoverflow 线程指出此行为是“设计使然”的:

How do I prevent an image from overflowing a rounded corner box with CSS3?

然而,在挖掘 CSS3 背景和边框的工作草案时......

http://www.w3.org/TR/css3-background/#corner-clipping

...我不禁注意到“Angular 裁剪”部分下的以下描述:

Other effects that clip to the border or padding edge (such as ‘overflow’ other than ‘visible’) also must clip to the curve. The content of replaced elements is always trimmed to the content edge curve

那我错过了什么?内容应该被剪到 Angular 落吗?我在看过时的信息吗?我做错了吗?

最佳答案

如果您在两个元素上都删除 position: relative;,则外部元素会将子元素剪裁在圆 Angular 周围。不知道为什么,如果它是一个错误。

关于html - CSS3 border-radius 裁剪问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3248734/

相关文章:

php - 如果选择了所有子元素,则隐藏父元素

html - css中是否有等同于背景图像的前景?

javascript - 如何勾画一个长跨度的标签?

javascript - 如何通过 Angular 4 中的 App Component 访问私有(private)属性?

javascript - Threejs Canvas 不会调整到标签 div

转换 : all used? 时,JQuery Slide Toggle 在这个粘性页脚上不起作用

html - 如何选择一个没有前n个字符和最后m个字符的字段?

html - 我可以将 li padding 设置为 auto 以使其适合 ul 宽度吗?

html - 在文本下方对齐下拉菜单

javascript - 使用 Bootstrap 的 Photoswipe 画廊