Subscribe

RSS Feed | RSS Email | Twitter
 

Sponsors

 

Search / Categories

 

CSS3 Shadows (Border, Images & Text)

Posted on January 11th, 2009 by Zen Elements 5 Comments

CSS3 Border & Text Shadows

Shadows have been around since the beginning of CSS2, however the only browser supporting them then (and continually now) was Safari. Shadows can be applied in CSS3 to text and borders, as well as affecting images as well. There is also a quick + / – to which browsers support the box-shadow and text-shadow CSS3 effect.

The CSS3 box-shadow & text-shadow is written box-shadow: Apx Bpx Cpx #XXX;
- Apx = x-axis
- Bpx = y-axis
- Cpx = cast length / feathering
- #XXX = colour as usual

So now knowing this, we can start experimenting in the following ways…

Alert

Cross Brower Compatability
As previously mentioned in An introduction to CSS3, not all current browsers support CSS3 yet. The browser that best supports the CSS3 shadow effects is Safari, which means we will concentraite on using the -webkit- prefix.
All articles in the CSS3 will be updated to show future support & development.

This is a panel set with a 5 by 5 pixel box-shadow, cast by 7px.

  1. CSS3 Border Shadow
  2. #my_CSS3_id {
  3.   border: 5px solid #111;
  4.   -webkit-box-shadow: 5px 5px 7px #999;
  5.   -webkit-border-bottom-right-radius: 15px;
  6.   padding: 15px 25px;
  7.   height: inherit;
  8.   width: 590px;
  9. }

This effect can also be applied to images… image

Current Browser Support (Tested, Jan 2009)

  • FireFox (3.0.5) – [FireFox (3.1 PreAlpha) is compatible]
  • Google Chrome (1.0.154.36)
  • Internet Explorer (IE6, IE7, IE8…)
  • Opera (9.6)
  • Safari (3.2.1, Windows)

An example for those on alternative browsers, not seeing the border-shadow effect..

 

HELLO CSS3 WORLD!

The above header has the following CSS 3 applied to it:

  1. CSS3 Text Shadow (Single)
  2. .my_CSS3_class {
  3.   font-size: 3.2em;
  4.   color: #F5F5F5;
  5.   text-shadow: 3px 3px 7px #111;
  6.   text-align: center;
  7. }

HELLO CSS3 WORLD!

The above header has the following CSS 3 applied to it:

  1. CSS3 Text Shadow (Multiple)
  2. .my_CSS3_class {
  3.   font-size: 3.2em;
  4.   color: #FFF;
  5.   text-shadow: 0px -11px 10px #C60, 0px -3px 9px #FF0;
  6.   text-align: center;
  7.   padding: 10px 0px 5px 0px;
  8.   background: #151515;
  9. }

Current Browser Support (Tested, Jan 2009)

  • FireFox (3.0.5) – [FireFox (3.1 PreAlpha) is compatible]
  • Google Chrome (1.0.154.36)
  • Internet Explorer (IE6, IE7, IE8…)
  • Opera (9.6) – [Also supporting multiple text shadows]
  • Safari (3.2.1, Windows)

An example for those on alternative browsers, not seeing the text-shadow effect..

 

Zen Elements Blog | CSS3 Series

Thanks for reading,
Alex | Zen Elements


 
RSS
Facebook
StumbleUpon

Comments (5)

Nick CowieJanuary 13th, 2009 at 4:13 am

There is a little bug with Chrome when box-shadow and border-radius is combined, shows in your example but not as disastrous as mine http://nickcowie.com/2008/google-chrome-is-frustrating-me/

Zen ElementsJanuary 13th, 2009 at 9:13 am

@Nick, hello. Thank you for stopping by and giving your feedback. Always appreciate it.
I see how you mean in your example for those CSS buttons, which is a good idea in itself. It is a great nuisance that even the newer browsers are giving poor support to the progression of CSS3 so I agree wholeheartily with when you argue ‘why we should care?’ in your post. If we want to see CSS3 (and the future generation languages), we should care and show the browsers we care. *waves a fist at them all*

Alex | Zen Elements

Mountain/\AshJanuary 20th, 2009 at 10:33 pm

These style elements also work for Mozilla/Firefox but you have to add the vendor-specific “-moz” prefix. These are working fine for me using Firefox 3.1b2.

Zen ElementsJanuary 21st, 2009 at 11:54 pm

Thank you for the update. I will try get my hands on that version asap and amend after clarifying. Can see this will be a tricky series to keep tabs on so hurry up browsers and get compatible! ;)

alexMay 6th, 2009 at 7:12 am

Nice work on CSS3, more articles please

Leave a comment

Your comment

top
  • Zen Elements on Facebook
  • Zen Elements on Flickr
  • Zen Elements on Twitter
  • Zen Elements RSS Feed

© Zen Elements Ltd. 2008. All Rights Reserved. Sitemap | CSS | XHTML | Terms & Conditions