Tucked Corners

An Experiment in Awesomeness

Best viewed in a webkit browser

Skip to the updated, mozilla friendly code

Ever since I first visited the Gravatar home page, I knew that the corner effect could be achieved via CSS. After receiving some good news last night, I was having trouble sleeping so I thought I'd give it a shot.

My first experiment utilized box shadows. But I was unaware of the negative spread in the box shadow property. My second experiment utilized gradients, which nearly did the trick. Example, below:

View Fiddle

It wasn't until I was getting ready to pass out that I thought of posting on forrst. Not a minute later, I received a response from Last Rose Studios. You can see it as a fork of my original idea:

View Fiddle

When I woke up, I saw that Joshua Hibbert had posted exactly what I was looking for. Below is his final version. I've amended it for flexability.

View Fiddle

There are still some issues with mozilla rendering box shadow. So, for now, it's pretty much webkit only.

Scott Parry apparently helped fix the code to render better in mozilla.

Check below for the code:
			div.tucked-corners {
			    background: #f6f6f6;
			    height: 380px;
			    margin: 50px auto;
			    padding: 10px;
			    position: relative;
			    width: 580px;
			    box-shadow: 0 1px 7px hsla(0,0%,0%,.2);
			}
			span.tucked-corners {
			    background: #c4453c;
			    display: block;
			    height: 380px;
			    position: relative;
			    width: 580px;
			    box-shadow: inset 0 0 10px hsla(0,0%,0%,.25);
			}
			
			
			/* Top Corner Effect */
			
			.top-corners:after,
			.top-corners:before {
			    background: #e6e6e6;
			    content: '';
			    height: 50px;
			    position: absolute;
			    top: -25px;
			    width: 100px;
			    z-index: 10;
			    box-shadow: 0 6px 9px -8px hsla(0,0%,0%,.5);
			}
			.top-corners:after {
			    left: -50px;
			    transform: rotate(-45deg);
			}
			.top-corners:before {
			    right: -50px;
			    transform: rotate(45deg);
			}
			
			/* Bottom Corner Effect */
			
			.bottom-corners:after,
			.bottom-corners:before {
			    background: #e6e6e6;
			    content: '';
			    height: 50px;
			    position: absolute;
			    bottom: -25px;
			    width: 100px;
			    box-shadow: 0 6px 9px -8px hsla(0,0%,0%,.5);
			}
			.bottom-corners:after {
			    left: -50px;
			    transform: rotate(-135deg);
			}
			.bottom-corners:before {
			    right: -50px;
			    transform: rotate(135deg);
			}
			

We're sure this can still be improved on. So, feel free to grab a fiddle and work it out.

Update: Here's a bit of a different take, using overflow:hidden:

View Fiddle