Is there a way to apply a box-shadow to a div without it affecting specific other divs?
In simpler terms, is it possible to prevent shadows from being cast on a particular div?
Take for example this scenario: http://jsfiddle.net/Cd6fE/
How can I prevent the shadow generated by .p1
from appearing on .noShadowsOnMePlease
, while still casting a shadow on other divs?
If necessary, I am willing to use JavaScript or jQuery for a solution, but ideally, I'd prefer to achieve this using pure CSS.
Solution: Essentially, no, but you can create a workaround if the shadow is static. Alternatively, consider using css masking, although browser support may be limited as of Jan 2014. A good workaround without css masking can be found here: http://jsfiddle.net/zExS9/ - this method uses the :before
selector to conceal shadow sections and then hides overflow.
Wouldn't it be convenient to have an accepts-shadows: false;
attribute?