CSS3 Drop Shadows for Icons
Using some CSS radial gradients its fairly easy to create a drop shadow for icons, images, etc like so.
JSBin http://jsbin.com/ohusor/2/
<body>
<div>
<a href="">
<span class="shadow"> </span>
<img src="https://store.cerner.com/items/123/icon">
<span>link text</span>
</a>
</div>
</body>
</html>
.shadow {
position: absolute;
height: 7px;
width: 60px;
top: 80px;
left: 10px;
/*box-shadow: 1px 40px 40px -15px lightgray;*/
background-image: -moz-radial-gradient(50% 50%, ellipse closest-corner, rgba(171, 171, 171, 0.7), rgba(255, 254, 250, 0.7) 74%);
background-image: -webkit-radial-gradient(50% 50%, ellipse closest-corner, rgba(171, 171, 171, 0.7), rgba(255, 254, 250, 0.7) 74%);
background-image: -o-radial-gradient(50% 50%, ellipse closest-corner, rgba(171, 171, 171, 0.7), rgba(255, 254, 250, 0.7) 74%);
background-image: -ms-radial-gradient(50% 50%, ellipse closest-corner, rgba(171, 171, 171, 0.7), rgba(255, 254, 250, 0.7) 74%);
background-image: radial-gradient(50% 50%, ellipse closest-corner, rgba(171, 171, 171, 0.7), rgba(255, 254, 250, 0.7) 74%)
}
img {
position: absolute;
left: 10px;
height: 60px;
}
span {
position: absolute;
top: 25px;
left: 75px
}
Written by Dustin Smith
Related protips
1 Response
Nice idea! :)
You could even use the :after element to not have to use a span for the shadow.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#