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?
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.
Ok so I've answered my own question but I've read the Stackoverflow forums and it seems to be acceptable (if not actually encouraged!)
So...
HTML:
<html>
<head>
<TITLE>TEST</TITLE>
<link rel="stylesheet" type="text/css" href="test.css" />
</head>
<body>
<div id="wrap">
<div id="gradient">
</div>
</div>
</body>
</html>
CSS:
#wrap
{
overflow:hidden;
height:10px;
width:600px;
height:20px;
margin:auto;
margin-top:200px;
}
#gradient
{
height:20px;
width:580px;
margin:auto;
margin-top:-11px;
background: -moz-radial-gradient(center, ellipse cover, rgba(10,10,10,1) 0%, rgba(8,8,8,1) 19%, rgba(3,3,3,0) 80%, rgba(1,1,1,0) 100%); /* FF3.6+ */
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,rgba(10,10,10,1)), color-stop(19%,rgba(8,8,8,1)), color-stop(80%,rgba(3,3,3,0)), color-stop(100%,rgba(1,1,1,0))); /* Chrome,Safari4+ */
background: -webkit-radial-gradient(center, ellipse cover, rgba(10,10,10,1) 0%,rgba(8,8,8,1) 19%,rgba(3,3,3,0) 80%,rgba(1,1,1,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-radial-gradient(center, ellipse cover, rgba(10,10,10,1) 0%,rgba(8,8,8,1) 19%,rgba(3,3,3,0) 80%,rgba(1,1,1,0) 100%); /* Opera 12+ */
background: -ms-radial-gradient(center, ellipse cover, rgba(10,10,10,1) 0%,rgba(8,8,8,1) 19%,rgba(3,3,3,0) 80%,rgba(1,1,1,0) 100%); /* IE10+ */
background: radial-gradient(center, ellipse cover, rgba(10,10,10,1) 0%,rgba(8,8,8,1) 19%,rgba(3,3,3,0) 80%,rgba(1,1,1,0) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0a0a0a', endColorstr='#00010101',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
}
In order to reproduce that horizontal rule, you can use a CSS3 linear-gradient. Just create a div with about a 3px height and apply the following CSS (change the colors as needed):
background: #ffffff; /* Old browsers */
background: -moz-linear-gradient(left, #ffffff 0%, #2989d8 25%, #207cca 75%, #ffffff 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#ffffff), color-stop(25%,#2989d8), color-stop(75%,#207cca), color-stop(100%,#ffffff)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #ffffff 0%,#2989d8 25%,#207cca 75%,#ffffff 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, #ffffff 0%,#2989d8 25%,#207cca 75%,#ffffff 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, #ffffff 0%,#2989d8 25%,#207cca 75%,#ffffff 100%); /* IE10+ */
background: linear-gradient(left, #ffffff 0%,#2989d8 25%,#207cca 75%,#ffffff 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 */
Keep in mind that filter
does not support color stops, so you may want an image fall back for < IE10.
Build your own CSS3 gradient here: http://www.colorzilla.com/gradient-editor/
This code create a normal hr but the difference will is it will have both end with fade effect(gradient black to blue)
hr{
border-top-color: black;
margin-bottom: 25px;
width: 80%;
}
hr::before{
display: block;
margin-left: -10%;
margin-top: -1px;
content:"";
background: linear-gradient(to left, black, blue);
width: 10%;
height: 1px;
}
hr::after{
display: block;
margin-left: 100%;
margin-top: -1px;
content:"";
background: linear-gradient(to right, black, blue);
width: 10%;
height: 1px;
}