Posts Tagged ‘dropshadow’

IE Hack: CSS drop shadow

Thursday, May 6th, 2010

Easy-to-apply, dynamic, auto-expanding drop shadows have always been a bit of a pain to apply across all the major browsers. We fairly recently got the box-shadow attribute, which can be applied with -moz-box-shadow and -webkit-box-shadow on gecko and webkit browsers. But it leaves the IE family out in the cold.

The easiest solution to the is the IE-proprietary filter attribute. It does not producte quite as nice shadows as the box-shadow attribute, but for simple just-a-few-pixels drop shadows it does the trick. One noticeable drawback is that IE for some reason disables anti-aliasing on elements that has this attribute. But I can live with that in most cases.

This box has a shadow
.shadow {
	zoom:1; /* This enables hasLayout, which is required for older IE browsers */
	filter: progid:DXImageTransform.Microsoft.Shadow(color='#b0b0b0', Direction=135, Strength=3);
	-moz-box-shadow:2px 2px 2px #b0b0b0;
	-webkit-box-shadow:2px 2px 2px #b0b0b0;
	box-shadow:2px 2px 2px #b0b0b0;
}

This should look fairly similar in all major browsers, including IE 6+