Reputation: 27791
See here: http://jsfiddle.net/QSp2W/5/
As you can see the inner h1
has a background color which overlaps the rounded corners of the containing div
. This is sort of fixed if you set a smaller radius on the inner h1
but this is a hack. (Uncomment the commented CSS to see what I mean.)
http://jsfiddle.net/QSp2W/23/ but I don't know how to apply the *
selector to only direct children, not grandchildren.
Upvotes: 5
Views: 1453
Reputation: 34855
The most direct way is to have the div h1
inherit from the div
.
So border-radius: inherit;
instead of setting a radius #.
http://jsfiddle.net/jasongennaro/QSp2W/10/
Upvotes: 0
Reputation: 4536
Adding overflow: hidden
to the containing div
effectively gets the background to do what you want, but it seems to overwrite the border! So, not quite perfect... :)
Upvotes: 2
Reputation: 8966
I would give H1
and p
the CSS properties instead of the div as below. You could create a class just for borders and apply them to the appropriate element.
CSS:
div h1
{
padding: 2px;
background-color: #ff0000;
border-top: 2px solid #000000;
border-left: 2px solid #000000;
border-right: 2px solid #000000;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
/* Below gets it close but not quite. */
/*border-radius: 7px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;*/
}
div p
{
padding: 10px;
border-left: 2px solid #000000;
border-right: 2px solid #000000;
border-bottom: 2px solid #000000;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
This is with separate border class: http://jsfiddle.net/QSp2W/9/
Upvotes: 1