Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Box-shadow and border-radius bug in Chrome

I've been experimenting with CSS3 and found something strange. Heres's the part of DIV style:

border:#446429 solid 1px;
border-radius:15px;
-moz-border-radius:15px;
-webkit-border-radius:15px;
box-shadow:3px 0px 15px #000000 inset,0px 3px 15px #000000 inset;
-moz-box-shadow:3px 0px 15px #000000 inset,0px 3px 15px #000000 inset;
-webkit-box-shadow:3px 0px 15px #000000 inset,0px 3px 15px #000000 inset;

Rendering in Opera and Firefox are same and perfect:

alt text

But Chrome renders shadow outside the border:

alt text

Is it supposed to be so or I missed something important?

like image 370
Klaster_1 Avatar asked May 30 '10 06:05

Klaster_1


People also ask

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. This answer worked for me.

Does Box Shadow work on all browsers?

BROWSER SUPPORT FOR CSS3 Box-shadowCSS3 Box-shadow is supported by Chrome browser version 10 to Chrome browser version 67.

How do I get rid of Webkit shadow?

The box-shadow styles are used to pay attention to the content. Primer CSS Box Shadow Remove style is mainly used to remove the box-shadow. To remove the box-shadow, we will add an additional class . box-shadow-none.

What is HTML box shadow?

The box-shadow CSS property adds shadow effects around an element's frame. You can set multiple effects separated by commas. A box shadow is described by X and Y offsets relative to the element, blur and spread radius, and color.


3 Answers

It looks like a known bug:

http://code.google.com/p/chromium/issues/detail?id=29427

Check out the bug discussion, you may find a workaround. Definitely Star this bug if you want it to be fixed sooner!

like image 150
dmazzoni Avatar answered Sep 24 '22 13:09

dmazzoni


Putting in first an inset shadow that is the same colour as the background seems to work pretty well without putting extra markup on your page.

E.g. if you had a white background page :

-webkit-box-shadow:1px 1px 1px #fff inset,0px 0px 5px #333 inset;
like image 41
Beth Faulds Avatar answered Sep 25 '22 13:09

Beth Faulds


I just found fix, but it needs additional markup. We need place element with round corners and inner shadow into another container with the same round corners and overflow hidden.

<div class="foo"><div>Hello!</div></div>
<style type="text/css">
    .foo {-webkit-border-radius: 10px; overflow: hidden;}
    .foo div {-webkit-border-radius: 10px; -webkit-box-shadow: inset 1px 1px rgba(50%, 50%, 50%, .5);}
</style>

Announced above fix with border crashes border radius and is incompartible with background image under element (because of border color).

Thanks.

like image 29
Tony Avatar answered Sep 23 '22 13:09

Tony