Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

border-radius + background-color == cropped border

Consider a div with the border-radius, border, and background-color CSS attributes applied:

<div style="background-color:#EEEEEE; border-radius:10px; border: 1px black solid;">    Blah  </div>

enter image description here

Now consider a similar layout but with the background-color specified in an inner-div:

<div style="border-radius:10px; border: 1px black solid;">    <div style="background-color:#EEEEEE;">      Blah    </div>  </div>

enter image description here

I'm dismayed by the fact that the background-color of the inner <div> is obscuring the border of the outer <div>.

This is a simplified sample of the problem. In reality, I'm using a <table> as the inner element with alternating row colors. And I'm using a <div> as the outer element since border-radius does not seem to work on the <table> element. Here's a jsfiddle of a sample of this problem.

Does anyone have a suggestion for a solution?

like image 549
Kirk Woll Avatar asked Jun 10 '11 21:06

Kirk Woll


People also ask

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.

How do you put a radius on a border in CSS?

CSS Syntaxborder-radius: 1-4 length|% / 1-4 length|%|initial|inherit; Note: The four values for each radius are given in the order top-left, top-right, bottom-right, bottom-left. If bottom-left is omitted it is the same as top-right. If bottom-right is omitted it is the same as top-left.

Can I color border in CSS?

The border-color property is used to set the color of the four borders. The color can be set by: name - specify a color name, like "red"


1 Answers

Try overflow:hidden in the outer div:

<div style="border-radius:10px; border: 1px black solid; overflow: hidden">    <div style="background-color:#EEEEEE;">      Blah    </div>  </div>
like image 133
Dotan Avatar answered Oct 11 '22 08:10

Dotan