Skip to content

Instantly share code, notes, and snippets.

@kulor
Created August 3, 2012 13:32
Show Gist options
  • Save kulor/3247733 to your computer and use it in GitHub Desktop.
Save kulor/3247733 to your computer and use it in GitHub Desktop.
ie image dropshadow support
/*
Dropshadow handling in IE vs. native box-shadow support
- Normal box-shadow on .dropshadow
/////////////////////
/ +===============+ /
/ | | /
/ | | /
/ | | /
/ | | /
/ +===============+ /
/////////////////////
- IE filter on .dropshadow
+===============+
|///////////////|
|/ /|
|/ /|
|///////////////|
+===============+
If we observe the above dropshadow techniques we can use,
you will notice the difference of an inner vs. outside dropshadow.
For this reason, we need handle IE in it's own special way to get the placement
looking like it sits around the element.
If the margin and padding were not applied to the dropshadow in IE it would look like the below diagram.
We therefore need to pull the top-left in to meet the img top-left and
push the bottom-right up and in to meet the bottom-right of the img.
+===============+ +===============+
| img | .dropshadow | img |
| +---------------+ z-index: -1; | |-+
| | |      -> | | |
| | | | | |
+=| | +===============+ |
| .dropshadow | | .dropshadow |
+---------------+ +---------------+
As the .dropshadow is using filter, this means the whole element is filled
with a black center and blurred/feathered edges. We therefore need to push
the element back in the z-stack so it doesn't overlay and obscure the image.
*/
.dropshadow{
margin-top: -6px;
margin-right: 6px;
margin-bottom: 6px;
margin-left: -6px;
filter:progid:DXImageTransform.Microsoft.Blur(
PixelRadius='6',
MakeShadow='true',
ShadowOpacity='0.75'
);
z-index: -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment