demosthenes.info

I’m Dudley Storey, the author of Pro CSS3 Animation. This is my blog, where I talk about web design and development with , and . To receive more information, including news, updates, and tips, you should follow me on Twitter.

featured articles

popular favourites

CSS Masks: Radial Vignettes

Traditional photographic vignettes – the effect seen when filming a projected image, or in photos taken with old box cameras – have more of a “pincushion” appearance, with shadows becoming more visible at the corners of the image and less at the sides. The previous example in this used an inner box-shadow on a background image, and therefore tended to a rectangular appearance: any circular shadowing effect we achieved was due solely to curving the border of the element with border-radius. But when we keep the corners of the element’s box at right angles, and combine that same technique with a radial gradient:

  1. p#brooklyn-bridge {
  2. width: 768px; height: 498px; background-image:
  3. -moz-radial-gradient(center, ellipse closest-side, rgba(0,0,0,0),
  4. rgba(0,0,0,0.6)), url(brooklyn-bridge.jpg);
  5. background-image: -webkit-radial-gradient(center, ellipse closest-side,
  6. rgba(0,0,0,0), rgba(0,0,0,0.6)), url(brooklyn-bridge.jpg);
  7. background-image: -ms-radial-gradient(center, ellipse closest-side,
  8. rgba(0,0,0,0), rgba(0,0,0,0.6)), url(brooklyn-bridge.jpg);
  9. background-image: -o-radial-gradient(center, ellipse closest-side,
  10. rgba(0,0,0,0), rgba(0,0,0,0.6)), url(brooklyn-bridge.jpg);
  11. background-image: radial-gradient(center, ellipse closest-side,
  12. rgba(0,0,0,0), rgba(0,0,0,0.6)), url(brooklyn-bridge.jpg);
  13. box-shadow: inset 0 0 40px rgba(0, 0, 0, 1); color: rgba(0, 0, 0, 0);
  14. overflow: hidden; text-align: center; margin: 0 auto; }

…with an photograph by Stephen Cho, we get the effect you see at the top of this article. (Note that I am using the most recent version of the CSS3 radial gradient specification, together with support for multiple backgrounds. You will have to write extra CSS for older browsers).

You must be signed up in order to leave comments.

web developer guide

featured comment

by Aisling Brock in New Business Card Design

what i'm reading

A Feast for Crows: A Song of Ice and Fire: Book Four
A Feast for Crows: A Song of Ice and Fire: Book Four

what i'm watching

Prometheus: Collector's Edition (Bilingual) [Blu-ray 3D + Blu-ray + DVD + Digital Copy]
Prometheus: Collector's Edition (Bilingual) [Blu-ray 3D + Blu-ray + DVD + Digital Copy]

what i'm playing

Borderlands
Borderlands

what i'm hearing

Planets
Planets

blogs

podcasts

no ads ever

This blog is free of advertising, and always will be.

creative commons licensed

The content of this blog is free to use in whatever way you wish under the Creative Commons license.