public
Last active

Simple Bended-Shadow CSS: Create the Bended Photo Effect without writing a million divs.

  • Download Gist
bending-shadow.css
CSS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
.bended-shadow {
position: relative;
width: 500px;
margin: 200px auto;
}
 
.bended-shadow::before, .bended-shadow::after {
content: '';
position: absolute;
width: 60%;
height: 30px;
-webkit-box-shadow: 0 0 36px rgba(0,0,0,1);
-moz-box-shadow: 0 0 36px rgba(0,0,0,1);
-ms-box-shadow: 0 0 36px rgba(0,0,0,1);
-o-box-shadow: 0 0 36px rgba(0,0,0,1);
box-shadow: 0 0 36px rgba(0,0,0,1);
-webkit-transform: rotate(-3deg) skew(-10deg);
-moz-transform: rotate(-3deg) skew(-10deg);
-o-transform: rotate(-3deg) skew(-10deg);
-ms-transform: rotate(-3deg) skew(-10deg);
transform: rotate(-3deg) skew(-10deg);
left: 16px; /* Decrease px to increase spread */
bottom: 17px; /* Decrease to lower shadow */
z-index: 0; /* Important! should be (-1) beneath your content container */
}
 
.bended-shadow::after {
-webkit-transform: rotate(3deg) skew(10deg);
-moz-transform: rotate(3deg) skew(10deg);
-o-transform: rotate(3deg) skew(10deg);
-ms-transform: rotate(3deg) skew(10deg);
transform: rotate(3deg) skew(10deg);
left: auto;
right: 16px; /* Decrease px to increase spread */
}
 
#content {
position: relative;
bottom: 4px;
padding: 3px;
background-color: #FFF;
min-height: 400px;
border: 1px solid #D0D0D0;
border-bottom: 1px solid #CACACA;
z-index: 1;
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,.1);
-moz-box-shadow: 0 1px 1px rgba(0,0,0,.1);
-ms-box-shadow: 0 1px 1px rgba(0,0,0,.1);
-o-box-shadow: 0 1px 1px rgba(0,0,0,.1);
box-shadow: 0 1px 1px rgba(0,0,0,.1);
}
 
#photo {
background-color: #EEE;
border: 1px solid #D0D0D0;
min-height: 408px;
-webkit-box-shadow: inset 0 0 3px rgba(0,0,0,.09);
-moz-box-shadow: inset 0 0 3px rgba(0,0,0,.09);
-ms-box-shadow: inset 0 0 3px rgba(0,0,0,.09);
-o-box-shadow: inset 0 0 3px rgba(0,0,0,.09);
box-shadow: inset 0 0 3px rgba(0,0,0,.09);
}
 
h1 {
font-family: 'Helvetica Neue';
font-weight: bold;
font-size: 90px;
text-align: center;
padding-top: 70px;
color: #818486;
letter-spacing: 0;
text-shadow: 0 -1px 0 rgba(0,0,0,.5), 0 2px 1px rgba(255,255,255,.6);
}
bending-shadow.html
HTML
1 2 3 4 5
<div class="bended-shadow">
<div id="content">
Put your Content/Image here.
</div>
</div>

Peep the source/demo here. OR check out the zoomed-in shot below.

Bended Shadow CSS

Made a Compass mixin out of this one too, but it needs a little work. If the container is shorter than 80px or wider than 500px you can see the corners of the :before and :after.

Now I'm wondering how hard it would be to do the same with your gradient borders lol

Really nice one this and that another backwards bent shadows.

Just to point out, the skew css transformation is removed from CSS3 spec working draft and replaced with skewX and skewY. More about that in https://developer.mozilla.org/en/CSS/transform#skew_Non-standard and the spec: http://www.w3.org/TR/css3-2d-transforms/

This gist snippet should work just fine by replacing the skew with skewX since your transforming against X-axis. Works at least on latest Google Chrome and Firefox, but haven't tested in other browsers.

Way cool, thanks for sharing!!! I thought I'd have to use PS to get this done.. Not being a designer I'm so stoked it is possible in css and that you shared!!!

great work!!,
Thank u so much

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.