Reputation: 12955
everyone know that box shadow can render completely different in IE than in chrome or Firefox (it's unbelievable for me). my question is how you handle this situation ? because the design can completely change in some case ... most of the time the box shadow on IE is little thin than on Chrome/Firefox. is their any java-script plugin that can automatically on IE increase a little the box shadow ?
Upvotes: 0
Views: 1379
Reputation: 5435
I think you should keep this in mind: http://dowebsitesneedtolookexactlythesameineverybrowser.com/
To clarify: you might want to rethink whether it really is that important that shadows are exactly the same width in every browser. It might not provide that different a feel, whereas little hacks like stating a width other than the desired one because it appears to be what you want in a specific browser on a specific operating system on specific hardware might have undesirable effects in setups that you're unable to test.
Upvotes: 1
Reputation: 11496
.shadow {
-webkit-box-shadow: 3px 3px 5px 6px #ccc; /* Safari 3-4, iOS 4.0.2 - 4.2, Android 2.3+ */
-moz-box-shadow: 3px 3px 5px 6px #ccc; /* Firefox 3.5 - 3.6 */
box-shadow: 3px 3px 5px 6px #ccc; /* Opera 10.5, IE 9, Firefox 4+, Chrome 6+, iOS 5 */
}
Thats:
box-shadow: [horizontal offset] [vertical offset] [blur radius] [optional spread radius] [color];
The horizontal offset (required) of the shadow, positive means the shadow will be on the right of the box, a negative offset will put the shadow on the left of the box.
The vertical offset (required) of the shadow, a negative one means the box-shadow will be above the box, a positive one means the shadow will be below the box.
The blur radius (required), if set to 0 the shadow will be sharp, the higher the number, the more blurred it will be, and the further out the shadow will extend. For instance a shadow with 5px of horizontal offset that also has a 5px blur radius will be 10px of total shadow.
The spread radius (optional), positive values increase the size of the shadow, negative values decrease the size. Default is 0 (the shadow is same size as blur).
Color (required) - takes any color value, like hex, named, rgba or hsla. If the color value is omitted, box shadows are drawn in the foreground color (text color). But be aware, older WebKit browsers (pre Chrome 20 and Safari 6) ignore the rule when color is omitted.
Using a semi-transparent color like rgba(0, 0, 0, 0.4) is most common, and a nice effect, as it doesn't completely/opaquely cover what it's over, but allows what's underneath to show through a bit, like a real shadow.
Internet Explorer (8 and down) Box Shadow
You need an extra element, but it's do-able with filter.
<div class="shadow1">
<div class="content">
Box-shadowed element
</div>
</div>
.shadow1 {
margin: 40px;
background-color: rgb(68,68,68); /* Needed for IEs */
-moz-box-shadow: 5px 5px 5px rgba(68,68,68,0.6);
-webkit-box-shadow: 5px 5px 5px rgba(68,68,68,0.6);
box-shadow: 5px 5px 5px rgba(68,68,68,0.6);
filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius=3,MakeShadow=true,ShadowOpacity=0.30);
-ms-filter: "progid:DXImageTransform.Microsoft.Blur(PixelRadius=3,MakeShadow=true,ShadowOpacity=0.30)";
zoom: 1;
}
.shadow1 .content {
position: relative; /* This protects the inner element from being blurred */
padding: 100px;
background-color: #DDD;
}
source : css-tricks
Upvotes: 0