开发者

Rounded Corners in Parent DIV not effecting Child DIVs

开发者 https://www.devze.com 2023-02-16 02:54 出处:网络
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.The problem I\'m having is tha

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. The problem I'm having is that there are child DIVs that are not getting "masked" by the parent's rounded corners. 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.

Does anyone have any ideas how the children of the rounded-cornered container DIV can be sorta masked by the parent DIV? If it's of any use, I'm using "position: absolute;" on the parent DIV. Not sure if that wi开发者_开发技巧ll make any difference.

Thanks!


Try adding overflow: hidden; to the parent element. This fixed the problem for me.


Use padding on the 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/.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号