There is a glaring problem with box-shadow. As the name implies, it is limited to the rectangular CSS box shape of the element it is applied to. Here's a screen grab of a triangle shape made with CSS (you can view the code in example_06-08) with a box shadow applied:

Not exactly what I was hoping for. Thankfully, we can overcome this issue with CSS filters, part of the Filter Effects Module Level 1 (http://www.w3.org/TR/filter-effects/). They are not as widely supported as box-shadow, but work great with a progressive enhancement approach. If a browser doesn't understand what to do with the filter it simply ignores it. For supporting browsers, the fancy effects are rendered.
Here is that same element with a CSS drop-shadow filter applied instead of a box-shadow:

Here is the format for CSS filters:
.filter-drop-shadow {
filter: drop-shadow(8px 8px 6px #333);
}After the filter property we specify the filter we want to use, drop-shadow in this example, and then pass in the arguments for the filter. The drop-shadow follows a similar syntax to box-shadow so this one is easy; x and y offset, blur, then spread radius (both optional), and finally color (also optional, although I recommend specifying a color for consistency).
CSS filters are actually based upon SVG filters which have a wider support. We'll look at the SVG based equivalent in Chapter 7, Using SVGs for Resolution Independence.
There are a few filters to choose from. We will look at each. While images of most of the filters follow, readers reading a hard copy of this book (with monochrome images) may struggle to notice the differences. If you're in that situation, remember you can still view the various filters in the browser by opening example_06-08. I'm going to list each out now with a suitable value specified. As you might imagine, more of a value means more of the filter applied. Where images are used, the image is shown after the relevant code.
filter: url ('./img/filters.svg#filterRed'): Lets you specify an SVG filter to use.filter: blur(3px): Use a single length value (but not as a percentage).
filter: brightness(2): Use a value from 0 to 1 or 0% to 100%. 0/0% is black, 1/100% is 'normal,' and anything beyond brightens the element further.
filter: contrast(2): Use a value from 0 to 1 or 0% to 100%. 0/0% is black, 1/100% is 'normal,' and anything beyond raises the color contrast.
filter: drop-shadow(4px 4px 6px #333): We looked at drop-shadow in detail earlier.filter: grayscale(.8): Use a value from 0 to 1, or 0% to 100% to apply varying amounts of grayscale to the element. A value of 0 would be no grayscale while a value of 1 would be fully grayscale.
filter: hue-rotate(25deg): Use a value between 0 and 360 degrees to adjust the colors around the color wheel.
filter: invert(75%): Use a value from 0 to 1, or 0% to 100% to define the amount the element has its colors inverted.
filter: opacity(50%): Use a value from 0 to 1, or 0% to 100% to alter the opacity of the element. This is similar to the opacity property you will already be familiar with. However, filters, as we shall see, can be combined and this allows opacity to be combined with other filters in one go.
filter: saturate(15%): Use a value from 0 to 1, or 0% to 100% to de-saturate an image and anything above 1/100% to add extra saturation.
filter: sepia(.75): Use a value from 0 to 1, or 0% to 100% to make the element appear with a more sepia color. 0/0% leaves the element 'as is' while anything above that applies greater amounts of sepia up to a maximum of 1/100%.
You can also combine filters easily; simply space separate them. For example, here is how you would apply opacity, blur, and sepia filters at once:
.MultipleFilters {
filter: opacity(10%) blur(2px) sepia(35%);
}I think you'll agree, CSS filters offer some pretty powerful effects. They are also effects we can transition and transform from situation to situation. We'll look at how to do that in Chapter 8, Transitions, Transformations, and Animations.
However, before you go crazy with these new toys, we need to have a grown up conversation about performance.