Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Border-radius doesn't affect inner elements

Tags:

css

less

I have a layout where the all of the page content is in a box with rounded corners. This includes the title of the page, etc. I have a div element that contains my header content, a div that contains the main content of the page, and a div that contains the footer. My problem is this: Since the border of my "header" div is not rounded, the large "container" div seems to not be rounded at the top. I have investigated, and shown that this is simply the "header" div superimposing itself over the "container" div. I have an example here: http://jsfiddle.net/V98h7/.

I have tried rounding the border of the "header" div to the same extent, but this creates a small defect on the border (it gains a border of its own, of the "header" div's background color). Out of desperation, I also tried setting the z-index of the container to a large number. THat did not do anything.

I feel that there should be a simple solution to this problem. I do not want a javascript fix. I would prefer CSS, but LESS is ok too.

like image 343
diracdeltafunk Avatar asked Jun 13 '12 05:06

diracdeltafunk


People also ask

What does the Border radius do?

The border-radius CSS property rounds the corners of an element's outer border edge. You can set a single radius to make circular corners, or two radii to make elliptical corners.

What is the difference between border and border radius?

The only difference between them is the right button has a radius of 5px applied. As with borders, radius allows you to set different properties for each side of the element using the toggle controls.

What does border radius inherit mean?

Definition and Usage The border-radius property defines the radius of the element's corners. Tip: This property allows you to add rounded corners to elements! This property can have from one to four values.

Which border property adds rounded border to an element?

The CSS border-radius property defines the radius of an element's corners. Tip: This property allows you to add rounded corners to elements!


1 Answers

Here is the fiddle - http://jsfiddle.net/ashwyn/V98h7/2/

Add -

#outer {    overflow: hidden; } 

and it will work.

More information on the overflow property can be found on MDN.

like image 178
Ashwin Avatar answered Oct 10 '22 09:10

Ashwin