Skip to content

Instantly share code, notes, and snippets.

@chriseppstein
Created May 6, 2011 09:10
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save chriseppstein/958668 to your computer and use it in GitHub Desktop.
Save chriseppstein/958668 to your computer and use it in GitHub Desktop.

A pure CSS bendy shadow:

I suspect that some trig calculations could make this very general.

bendy_shadow

@mixin bendy-shadow($width, $angle: 5deg, $color: rgba(#333, 0.5)) {
position: relative;
z-index: 1;
@include box-shadow(0 10px 5px -5px $color);
&:before, &:after {
content: "";
position: absolute;
bottom: 2px;
width: $width / 2;
height: 10px;
z-index: -1;
@include box-shadow(0 10px 10px 1px $color);
}
&:before {
left: 10px;
@include rotate(-$angle);
}
&:after {
right: 10px;
@include rotate($angle);
}
}
#photo-widget {
.no-boxshadow &, .no-csstransforms & {
.viewport {
padding-bottom: image-height('local/provider/photo-shadow-left.png') + 1px;
background: transparent image-url('local/provider/photo-shadow-left.png') no-repeat bottom left;
}
.shadow {
background: transparent image-url('local/provider/photo-shadow-right.png') no-repeat bottom right;
height: image-height('local/provider/photo-shadow-right.png');
width: image-width('local/provider/photo-shadow-right.png');
position: absolute;
bottom: 0;
right: 0;
}
}
.boxshadow.csstransforms & {
.viewport {
@include bendy-shadow(250px);
}
.shadow {
display: none;
}
}
}
@hoverlover
Copy link

Shouldn't I just be able to copy/paste this mixin into my sass file and it work? I'm getting a syntax error on line 1:

Syntax error: Invalid CSS after "...ba(#333, 0.5)) ": expected expression (e.g. 1px, bold), was "{"

@hoverlover
Copy link

OK, nm. I am using the indented syntax, so of course this won't work as-is.

@MarioRicalde
Copy link

This is sexy. Thanks for sharing boss!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment