CSS fade out horizontal rule / line styled div effect without images

ja_him picture ja_him · Feb 24, 2012 · Viewed 37.2k times · Source

I'm a big fan of minimal use of images and was wondering if anyone had a tactic (or if it's possible) to create this kind of thing with pure static CSS?

http://www.flickr.com/photos/jahimandahalf/6780397612/

I'm referring an effect of a line seemingly getting skinnier and fading out and the shadow effect underneath it.

I was thinking it might be possible to do a CSS shape trick with it like the triangles:

http://css-tricks.com/snippets/css/css-triangle/

Or perhaps with rotation on box-shadow using 'transform':

zenelements.com/blog/css3-transform/

Any ideas?

Answer

Andres Ilich picture Andres Ilich · Feb 25, 2012

You can use CSS3's stops and the :after pseudo-element to achieve such an effect. The trick is to add a border to the <hr> element by using the :after pseudo-element and position it in the center of the initial gradient with a soft color that ends with the gradient.

Here is a quick demo, and another demo using some color.