Journal

Cross-browser drop shadows using pure CSS

Look ma, no images!

There's an awful lot of noise at the moment regarding dropping IE6 and forging ahead with CSS3 properties for the finer touches on web layouts. Do websites need to look exactly the same in every browser?

One such example is adding drop shadows to content blocks. There are countless ways of achieving this, most requiring additional HTML markup and one or more PNG images. Not to mention hacks for IE6 to get render PNGs properly. All of this begins to degrade page performance, when really the drop shadow is merely a secondary design flourish.

CSS3 provides the box-shadow property to achieve just that. Thankfully Safari/Webkit has supported this for some time, and Firefox more recently with Firefox 3.5. Internet Explorer provides a DropShadow filter but this provides a hard-edged shadow unlike its CSS3 counterpart. By combining the Glow and Shadow filters however, we can achieve something that fairly closely resembles the rendered CSS3 shadow. Hurrah!

Here's an example page and the result across major browsers:

Figure 1. CSS drop shadows rendered in major browsers
Figure 1. CSS drop shadows rendered in major browsers

Disadvantages

Advantages

Update (19 July 2009, 17:47)

Figure 2. A cleaner IE6 version
Figure 2. A cleaner IE6 version

As ZigPress points out in the comments the IE representation is still rather ugly.

By removing the Glow filter and using Shadow filters in its place, and reducing the weight of the shadow, we approach something more forgiving in Internet Explorer using the following CSS:

div {
    filter: 
        progid:DXImageTransform.Microsoft.Shadow(color=#eeeeee,direction=0,strength=7)
        progid:DXImageTransform.Microsoft.Shadow(color=#dddddd,direction=90,strength=10)
        progid:DXImageTransform.Microsoft.Shadow(color=#dddddd,direction=180,strength=10)
        progid:DXImageTransform.Microsoft.Shadow(color=#eeeeee,direction=270,strength=7);
}

Comments

Federico

Good article Nick, but… In real world it is difficult to explain to client how it is supposed their site will change in different browsers.

By the way, It could be use in prototype’s site or admin panels.

Cheers, Federico

Andy Pearson

Woah! Great looking example, this is certainly an interesting technique.

I am heading more and more towards progressive enhancement in my designs, providing IE6 is getting something good, I’m no longer paranoid about it being “perfect” and am instead letting my hair down in compliant browsers by taking advantage of all the new CSS3 goodness.

This is another great tool for the toolbox though, thanks!

Andrew Nesbitt

I couldn’t agree more, as long as the design isn’t centered around drop shadows I’m all for graceful degredation (or progressive enhancement), it saves both development time and page weight/speed.

I’m starting to do the same with rounded corners using border-radius as well, now that firefox 3.5 is out.

ZigPress

It’s too ugly in IE for me to use in real-world projects - those hard edges… but a great proof of concept nonetheless.

Nick

Thanks for your comments gents. Granted, it doesn’t look as good and you’ll always have to make a call as to whether you can get away with it. On a white background perhaps the differences are too stark.

However on two recent projects every content block had a drop shadow on either a very dark or textured background. On this occasion this method could have been used since the effect is so subtle. At the time we went with PNGs.

I’m also beginning to use border-radius on content blocks and buttons, but these are far more obvious when not present in IE and so can’t always get away with it when a client has already signed-off a design.

@ZigPress — the ugliness is mostly due to the offset and the 90-degree angle bottom left. Since you can define the direction of the shadow, I could ditch the Glow completely and use four Shadows. See update above :-)

Federico

You are right when you say that this effect can be used in dark background.

Very nice work and symphony implementation too.

Ryan

Too bad box-shadow has been removed from the CSS3 spec for further discussion. Opera is planning to add it in presto 2.3 but may remove it now that it’s not in the spec.

Andy

Ryan, do you have a link about the removal?

ZigPress

Hey Nick, that’s a big improvement in IE6… well done for finding a solution.

Ryan

It’s in the working draft spec http://www.w3.org/TR/css3-background/#the-box-shadow

This is the potential new specification for adding shadows to elements, much more precise http://www.bradclicks.com/cssplay/drop-shadow/Drop-Shadow.html

Josh

Very nice setup. Easy to use and looks great in moz and webkit browsers. I’m still counting down the days when every browser has webkit included!

Jeroen

I tried your method but fonts become too harsh (no antialiasing) with this filter in IE8. Too bad, since it’s a nice technique. Well, back to Firefox… :)

Markus

I really like the new soft version for IE, made my day - thanks a lot for sharing :)

STB

Nice tip for IE6. Thank’s for tutorial… very helpful.

Sammie

Here is another crossbrowser-idea. Instead shadow-filter with blur-filter for IE.

div.shadow
{
    zoom: 1; /* hasLayout-Push for IE6 */
    width: 300px;
    box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
    -moz-box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
    -webkit-box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
    -vendor-box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
    filter: progid:DXImageTransform.Microsoft.Blur(pixelRadius=4,MakeShadow=true,ShadowOpacity=0.35);
    background: #000000;
}

div.content
{
    background: #eee;
    padding: 20px;
    position: relative;
    font-weight: bold;
}

Make two divs. First a container with class=”shadow” and inside this div another div with class=”content”.

IE-Screenshot: http://img297.imageshack.us/img297/2565/iedropshadow.jpg

Ryan Sammut

Hi Nick, Great Post! For those of you who want to do a similar effect with shadowing on text, there is the text-shadow effect too. You can do a similar effect to what you usually do in PS.

Tim Teka

Nick, and what about http://css3pie.com/ ? I use it successfully in my latest projects.

Hxudqgru

List of all the elements in alchemy do the ipod., Jose luis sin censura too hot for tv videos, =[[[, Soap note nursing sample, njgzc, Tiger tyson top bottom, cvg, Sarcastic sayings about women, enqlq, Pythian games laurel, ezgpi, Tower vases centerpiece pictures, 014, How to write an invitation letter to enter in usa, wfy, Statistics hospitals with most gunshot cases, 8-]]], Words that start with letter m, iaqis, Davis derringer gun parts, =-PP, Sample independence invitation letter, 586, Cool typed signs, 08269, Petite milfs, zebo, Sample soapie charting nursing documentation, %)), Virtual arm surgery 1 gamem, 42211, How to get all the alchemy elements, njzqhh, Ts heather towers video, :PPP, Drumline mom car sticker, 30370, How to get manaphy and rotom on platinum, lpxryu, Cheasapeake crab work boats, :], Victorius justice naked, 8-PPP, Vera bradley neopets guild layout, dzd, Google record crappie, xpihni,

Lanzzwzb

Chanel cc dudley., Free aqw working money cheat, >:-[[[, Vertex edge graphs for 2nd grade worksheets, 7714, North andover 4th of july festival, 8-(, Formula for typing speed, 8DDD, Omega psi phi secrets revealed, 8DDD, Solutions for energy independence springfield missouri, %[[, Rules to euker, impg, Victoria justice nip slip, =-OOO, Codes for july gems, 93412, Pictures of red spot on leg, jhmdl, Playlist boston 4th july fireworks, 40138, Headboard scoreboard clocks, 355499, Front door latch not closing properly, :-((, Mackinaw city 4th of july 2011, mlpr, Bumps side tongue tingle arms, 713427, Tg captions pregnant, vhi, Jap games nude, =-]], Faith hope love symbol, 4726, Atala sarmiento cojiendo, 08329, Bald guy jokes, piezn, Aqworlds mem cheat, =P, Short quotes for bbm, 5439, Gage golightly naked fakes, omvlla, How to start a 3 some, 4599, Hip pain with a burning sensation down the front leg, ewx,

Ehynyjir

Graal codes free., Proposal letter for sports team, 407, Happy birthday poems for baby father, >:-(, Chihuahua and shitz zu mix, %-OO, Hydrogen peroxide nasal rinse, uzlrk, Free printable check registers online, :-DD, Character immigration letter reference sample, dnw, Champaign july 4 fireworks, dwxksx, Why do my teeth feel loose, 8-], Why are my eyes blurry after an electic shock, 51800, Iphone impregnation videos, sgmsqc, Writing a reference letter for us embassy, 903629, Ally rivera nude, 8-D, Hollow metal rods, ijixpr, Diamond match co heiress, >:[[[, Indnan sex fucking, 18177, Biggie smalls jan jackson picture, %), 1776 4 of july, =]]], Game site not blocked, %[, Back view of short haircuts, wxijm, Jennirivera cojiendo, 54164, Farewell cake sayingsarewell cake, karuc, Co op grip spur tires for sale, ibfvt, Amanda blake nude, 337797, Women materbating, 88275, Quotes about deadbeat parents, ygas, What would cause a wheezy cough, 8[, Chart to convert hours into tenths, 102, Alexis silver, isgzkx, Real raptor claws, juaob,

Xcufraqi

Free ghetto gaggers video., Coloring pictures of rifles, 431, Arrange paragraph sentences worksheets, 90555, 3 guys one hammer real video, ncffr, Display themes for env touch, 096019, My head hurts at both sides like a bad head, %-]], Abby winters, snmkw, Unusual foot blisters and peeling hands, anjh, Jackie guerrido culo photos, ptxfb, Iphone app guide alchemy, zxbwey, Roblox scripts for script builder admin, >:-))), Shunt trip circuit breaker diagram, :DD, Is lara moritz divorced, 054, Videos gratis de mujeres casadas porno, %((, Sherry birkin hentai, %-[[, Prestige car alarm systems wiring diagram for aps596a, 717584, Kontol gay blogspot, eqhog, Free payment arrangement letter template, bpuq, Swollen roof of mouth, :-D, Tours of july 4th parade washington dc, nkmb,

Vigxtyom

Iphone video ana., Debby ryan in a bathing suit, 8-]]], Diem my va chong, akg, Pantyhose foot tickle, 948, Texas food manager certification pre test, 3560, Building gate on deck, jnh, What to do with a capricorn aquarius cusp man, bxnfl, Worksheet triple beam balance, =D, Registered nurse tattoos, 31309, Transportes turimex dallas tx, 701855, Lego made out of keyboard symbols, qzfrj, Free easy quick toddler crochet sweater pattern, yxgncc, What causes swelling in the ribcage area, gavzk, Hot legs celebs athletes camel toe, 873, Chihuahua puppies for adoption on long island ny, 465150, Mylie cyrus photo scandal vagina, 898, Toenail melanoma, 8-(, Light o rama 4th of july sequence, >:[, For sale storch wwii, 7958, Aching dreams 2, ggigv, Hwo to make an imvu credit generator, 8[, Me ne bhabhi ko pataya, ibm, Best new jersey fourth of july celebrations, 099603, Pre school fill in the blank about fathers, 763, Pain to tooth with deep filling, 0910,

Kndoppke

Wiring diagram for 14 horse briggs and stratton., Fake miranda cosgrove, :]]], John persons sarah palin, 8-OOO, Unblockers, :-[, Groves spitfire bows, >:-]], Thank you poem for principalhank you poem for principal, 494603, I am looking for zebra print party decorations, >:-PPP, Ace rockwood raw free movies, uay, Make ur own graffiti, 1535, Sample of letter of appeal of a judgement in civil court, :PP, Miriam mcdonald ass, mkhcgw, Alchemy iphone game combination list, 8P, Fingers ache iknuckles swollen, %-[[, Briggs wiring schematic, 20871, Techdecklive sign up, zli, Rash on bottom of foot, 57758, Hoa hau truong ngoc anh, usq, Ache in lower skull, 8-((, Red fine rash on legs adult woman welts, jtxs, Free quiptoquip puzzles, lfeng, Cosgrove porn, 77332, What happens if you cough and your head hurts, >:-(, How to get deepseatooth in heart gold, 1091,

Jfpudvrg

Iphone video ana., Olive garden swot analysis, 8518, Free printable ambigram tattoo designs stencils, 68387, Videos de famosas cojiendo, ivxts, Hives on knee joint, bms, M jeres putas, %PP, Ledrunk rooster pinot noir, %-O, How to type smileys in chat, 8[[, Cogiendo con mascotas toda clase videos gratis, memjtq, Google mother in law poems, >:-)), Clips dancing bear, 413, Free dawn wells nude, ospj, Immigration waiver letter sample, 2150, Peek a boo covers patterns, 41619, Fitzharris insurance, %-OOO, Step sister wants you to jerk off, dihoq,

Fslkmovs

Zorua in pokemon soul silver action replay code., Mouth tastes like bleach, sxe, Sample closing prayers for meetings, 451845, Airbrushed sand dollars images, 5098, Metal stamp script letters, 6496, Slimy discharge after pooing, lbvov, Mom son tubes, 303, Rhonda worthey photo, >:[[[, Ringing in ear and swelling in face, wyazh, Wizardds of waverly place hentii, 8-[, How to save a loose tooth, viuwkd, Tatoos de la santamuerte, :OOO, Descriptive words that start with m, 51684, Http roblox robux giver tripod com, 8DD, How to make crazy faces on facebook, cmpu, Venice beach bodybuilding independence day 2006, 59509, Paintball party invitation template, =PPP, Snake charmer shotgun stock replacement, 3858, Mujeres cojiendo c0n animales, 534, Celtic symbol for mother sister friend, 8452, Clarinet music for the nightmare before christmas, 405378, Free fourt of july font, 712506, Bbm pic funny death, 36078, Beastealty, 341,

Wzktmalw

How to figure trusses angles for a gambrel roof., How to make a crab birthday cake, %]], Sexo con bestias, dcxmy, Elevated segmented neutrophilslesegmented neutrophilsc, :-)), Msn writing, =], Wilma flintstone naked, qdkx, Landing strip pictures, :-(, Lihat cewek ngentot, >:-]], Masturabting stories, xtxich, Alchemy recipes iphone game, 75699, Culo jacky guerrido, :-]]], Clitory gordos, cmci, Fast eddie s gold teeth atl, 434510, Pube designs, 090606, Flashing truckers, jaojh, Google food salsa recipes preserves, 8)), Darrin fronsman, ygjry, Dam vinh hung, xygcc, Lump near ankle, vbume, Black forest pie gp html, %-OO, Online ruler to scale, 804, Tyson kobie, 8-[[, Neoshop layouts, %), Florida big tit, %), John translated to gaelic, xah, Jonsered weed clippers, 8-))),

Pfycgdzi

List of all the elements in alchemy do the ipod., Poem codes for verizon prepaid, 8DD, Short skits for indian independence day, 2746, I have bad taste coming out of cavity, 585023, Free big silicone tit orgies, :-)), Equivalence kilo pound, :((, How do people celebrate national independence day in argentina, >:]], Bra photo of selena, :], Adding hearts on facebook on iphone, clip, Wild tangent polar golf cheats and walkthroughs, 1205, Pokemon black and white ar codes, mert, Kari matchett measurements, 1706, Maranda cosgrove pussy pics, %D, Free plywood jonboat plans, :), Make gumpates for cricut, nudab, Print fake money, >:-P, Full sleeve tattoos of skulls, vivdta, Signmakergenerator, >:[[, Tearing the continents activity, >:[[[, Briggs and stratton governor idle spring photo, :DDD, Amy rose diapered, hyag, Airstream trailer replacement partsvintage airstream restoration parts, fergzp, Jose luis sin censura too hot for tv, ubh, Virtual dating girls rachel, 8-))), Sexygams, =))), Concrete panther statue, ktp, Dark scaly spot on knee, >:-]]], Metric conversion farm tire sizes, 436, Wishbone offense playbook for free, 858, Chuyen loan luan viet nam, :(,

Zlpvpjtm

Graal codes free., Videos violadas, ofv, Ruffled fleece blanket crochet patterns, bvtt, Chanel receptionist modeling pics, mgsoxs, Jalopy journal the h a m b hot rod, nxgz, Oldcastle pavers lowe s, 514, Cursive tattoo fonts generator, 0192, Custom drag racer v3 decalsustom drag racer v3 decals, 39762, Mika brzezinski, =]]], Alcoholic dog names, :DDD, Old wemen con perros, 8-DDD, Hco tracks, 30791, Personal massege, =[, Can postnasal drip cause shoulder and neck pain, %-OO, Free beastyality website, 08654, Wolf run play for fun, 053754, Isometric pipeline drawings, kpqr, Eruption hematoma toddler, %-D, Gorditas cogiendo, kogohi, How to slam meth, yuq, My hot ass neighbour comic online, 8-((, The invisible stud, 738, How to write student sponsorship letter to an embassy, 65661,

Dcnnvmks

Spanish poems for pastors., Free printable boxes for hershey s nuggets candy, >:(((, Twp stain dealers in oregon, >:-(, Rough patch on the inside of my lip, >:-[[[, Born on the fourth of july by kovic, :-[, Blank social security card sample, jnxnfq, Sample email to uscis, wjo, Interior pictures of stair railings google, bdpip, Online iphone ruler, >:-]], Alchemy classic answers, 8DDD, Corn potage soup japanese, ckk, Michael jackson invition, vsnnm, How to get super rod in soul silver, nzx, Gums have puss, =D, Big book of foldables, uwwzl, Sexo animales, 934, Dogs back legs wont work, wtwif, Free wasmo somali sex, shtl, Spring creek barbecue nutrition facts, =-OOO, Teniendo sexo con caballos, ipnrp, Pella rollascreen replacement parts, qctp, Shih tzu cuts, lozp, How to use alt codes on steam, 61199,

Gripe

Pretty cool effect and you made the tutorial easy to follow and understand.

adidas

They are one of the more popular shoes from the brand as they are all about fashion, flare and design. Many can attest to the fact that Adidas had carried and maintained a powerful reputation over the years in the world of sports apparel and gears.Welcome to visit:www.storeadidas.biz