简体   繁体   English

父DIV中的圆角不影响儿童DIV

[英]Rounded Corners in Parent DIV not effecting Child DIVs

So, I'm experimenting with using rounded-corners in CSS3 (not in IE, don't care if it works there), and I have the DIV where all of my content lives looking quite nice. 所以,我正在尝试在CSS3中使用圆角(不是在IE中,不关心它是否在那里工作),而且我有DIV,我的所有内容看起来都很漂亮。 The problem I'm having is that there are child DIVs that are not getting "masked" by the parent's rounded corners. 我遇到的问题是,有些孩子的DIV没有被父母的圆角“遮盖”。 I'm not looking for the child to inherit the rounded-corners. 我不是在寻找孩子继承圆角。 I just want to have any content inside the parent to not be visible where it is rounded, as if it were masked. 我只想让父母内部的任何内容在圆角处不可见,就像它被掩盖了一样。 I tried using "overflow: hidden;", but that doesn't seem to do the trick. 我尝试使用“overflow:hidden;”,但这似乎没有办法。

Does anyone have any ideas how the children of the rounded-cornered container DIV can be sorta masked by the parent DIV? 有没有人有任何想法如何圆形角容器DIV的孩子可以被父DIV掩盖? If it's of any use, I'm using "position: absolute;" 如果它有用,我正在使用“position:absolute;” on the parent DIV. 在父DIV上。 Not sure if that will make any difference. 不确定这是否会有所不同。

Thanks! 谢谢!

Try adding overflow: hidden; 尝试添加overflow: hidden; to the parent element. 到父元素。 This fixed the problem for me. 这解决了我的问题。

Use padding on the div. 在div上使用填充。 If you make the padding equal to the radius you shouldn't have to worry about any overlap or the content appearing in the rounded areas. 如果使填充等于半径,则不必担心任何重叠或内容出现在圆形区域中。

<style>
.round{
border-radius:10px;
padding:10px;
background-color:red;
}
</style>

<div class="round">Rounded Corners</div>

Here is a helpful site that talks all about the CSS3 Border Radius: http://www.css3.info/preview/rounded-border/ . 这是一个有用的网站,讨论CSS3 Border Radius: http//www.css3.info/preview/rounded-border/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM