Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Child elements bg color clips to parents border-radius

Anyone know of a surefire way to force child elements to stay in the border-radius of their parents?

Here is a js fiddle sample I'm working with: http://jsfiddle.net/fuego/qCNRZ/

Markup:

<div id="outer">
    <div id="inner">
        Nah nah nah<br/>
        Nah nah nah<br/>
        Nah nah nah<br/>
        Nah nah nah<br/>
        Nah nah nah<br/>
        Nah nah nah<br/>
        Nah nah nah<br/>
        Nah nah nah<br/>
    </div>
</div>

CSS:

#outer {
    width: 300px;
    background: red;
    border-radius:20px;

}

#inner {
    background:blue;
}

I simply want the container to appear blue now, but with the parents rounded edges. I updated the fiddle to reflect.

like image 208
Fuego DeBassi Avatar asked Oct 19 '11 17:10

Fuego DeBassi


People also ask

Does border-radius inherit?

CSS Demo: border-radius Note: As with any shorthand property, individual sub-properties cannot inherit, such as in border-radius:0 0 inherit inherit , which would partially override existing definitions. Instead, the individual longhand properties have to be used.

Why border-radius is not working?

If there are contents within the div that has the curved corners, you have to set overflow: hidden because otherwise the child div's overflow can give the impression that the border-radius isn't working.

How do you draw a border-radius to a table?

Use the CSS border-radius property to add rounded corners to the table cells.


1 Answers

Based on your example it would suffice to add overflow:hidden to your #outer element.

like image 174
Daan Mortier Avatar answered Oct 22 '22 23:10

Daan Mortier