octocatstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource
via CSS Lint

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource
via JS Hint

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Want a Run Button?

If active, the preview will update automatically when you change code.

HTML

            
              <!-- I made this demo to try out and illustrate some of the subtle button effects you can create just using box-shadow and borders on pseudo–elements.

Inspired by the work I saw a while back over on Beemuse (http://beemuse.com/paper) and so this is a heavily tweaked more dynamic version of those effects.

Also see Nicolas Gallaghers previous post on effects like this:
http://nicolasgallagher.com/css-drop-shadows-without-images/

Tested in latest Chrome and Firefox, but no reason it shouldn't work in all latest browsers. -->


<link href='http://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'>

<h2 class="no-separator">Raise on hover from flat</h2>
<a href="" class="btn paper-raise">Try Me</a>

<h2>Flatten on hover from raised</h2>
<a href="" class="btn paper paper-raise-flatten">Try Me</a>
  
<h2>Raise from Less flat position on hover</h2>
<a href="" class="btn paper paper-raise">Try Me</a>
  
<h2>Lift sides on Hover</h2>
<a href="" class="btn paper-lift">Try Me</a>
  
<h2>Flatten sides on hover</h2>
<a href="" class="btn paper-flatten">Try Me</a>
  
<h2>Curl right corner on hover</h2>
<a href="" class="btn paper paper-curl-right">Try Me</a>
  
<h2>Curl right side on hover</h2>
<a href="" class="btn paper paper-curl-right-side">Try Me</a>

<h2>Curl bottom corners on hover</h2>
<a href="" class="btn paper paper-curl">Try Me</a>
  
  
<h2>Group examples</h2>
<h2>Raise on hover</h2>
<ul>
  <li><a href="" class="btn paper-raise">Button One</a></li>
  <li><a href="" class="btn paper-raise">Button Two</a></li>
  <li><a href="" class="btn paper-raise">Button Three</a></li>
</ul>
  
<h2>Flatten on hover</h2>
<ul>
  <li><a href="" class="btn paper paper-raise-flatten">Button One</a></li>
  <li><a href="" class="btn paper paper-raise-flatten">Button Two</a></li>
  <li><a href="" class="btn paper paper-raise-flatten">Button Three</a></li>
</ul>
  
<h2>Less flat raise on hover</h2>
<ul>
  <li><a href="" class="btn paper paper-raise">Button One</a></li>
  <li><a href="" class="btn paper paper-raise">Button Two</a></li>
  <li><a href="" class="btn paper paper-raise">Button Three</a></li>
</ul>

<h2>Lift sides on hover</h2>
<ul>
  <li><a href="" class="btn paper-lift">Button One</a></li>
  <li><a href="" class="btn paper-lift">Button Two</a></li>
  <li><a href="" class="btn paper-lift">Button Three</a></li>
</ul>

<h2>Flatten sides on hover</h2>
<ul>
  <li><a href="" class="btn paper-flatten">Button One</a></li>
  <li><a href="" class="btn paper-flatten">Button Two</a></li>
  <li><a href="" class="btn paper-flatten">Button Three</a></li>
</ul>

<h2>Curl right corner on hover</h2>
<ul>
  <li><a href="" class="btn paper paper-curl-right">Button One</a></li>
  <li><a href="" class="btn paper paper-curl-right">Button Two</a></li>
  <li><a href="" class="btn paper paper-curl-right">Button Three</a></li>
</ul>
  
<h2>Curl right side on hover</h2>
<ul>
  <li><a href="" class="btn paper paper-curl-right-side">Button One</a></li>
  <li><a href="" class="btn paper paper-curl-right-side">Button Two</a></li>
  <li><a href="" class="btn paper paper-curl-right-side">Button Three</a></li>
</ul>

<h2>Curl bottom corners on hover</h2>
<ul>
  <li><a href="" class="btn paper paper-curl">Button One</a></li>
  <li><a href="" class="btn paper paper-curl">Button Two</a></li>
  <li><a href="" class="btn paper paper-curl">Button Three</a></li>
</ul>


<a href="http://twitter.com/AshNolan_" target="_blank" class="footerLink">made by @AshNolan_</a>

            
          
!

CSS

            
              /* Base page styles */

body {
  font-family: 'PT Sans', sans-serif;
  background-color: #f1f1f1;
  text-align: center;
}

h2 {
  text-transform: uppercase;
  font-size: 16px;
  margin-bottom: 0;
  padding-top: 20px;
  border-top: 1px solid #ccc;
  
  &.no-separator {
    border: none;
  }
}

ul {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  text-align: center;
}
  li {
    display: inline-block;
    margin: 0 20px;
  }


/* Base Button Style */
.btn {
  position: relative;
  display: block;
  width: 250px;
  margin: 20px auto;
  padding: 10px;
  
  background-color: #fff;
  border: 1px solid #ccc;

  color: #000;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  
  transform-style: flat;
  transition: all 250ms ease-out;
  
  &:before,
  &:after {
      content: "";
      position: absolute;
      z-index: -2;
    	transition: all 250ms ease-out;
  }
}

/* Paper effect – slightly raised off background */
.paper {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(128, 128, 128, 0.1) inset;
  border-color: #dedede;
}

/* Raised effect – pushes up on hover */
.paper-raise {
  &:before {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
  &:hover {
    border: 1px solid #fff;
    
    &:before {
			box-shadow: 0 15px 10px -10px rgba(31, 31, 31, 0.5);
    }
  }
}

.paper-raise-flatten {
  border-color: #fff;
  box-shadow: none;
  
  &:before {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: 0 15px 10px -10px rgba(31, 31, 31, 0.5);
  }
  &:hover {
    border-color: #dedede;
    
    &:before {
			box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(128, 128, 128, 0.1) inset;
    }
  }
}
	

/* Lift effect – lifts sides on hover */
.paper-lift {
	&:before,
	&:after {
		bottom: 15px;
     width: 50%;
     height: 20%;
     max-width: 300px;
     max-height: 100px;
    
		box-shadow: 0 10px 10px rgba(31, 31, 31, 0.5);
	}
  &:before {
    left: 8px;
    transform: rotate(-3deg);
	}
  &:after {
    right: 8px;
    transform: rotate(3deg);
	}
  
  &:hover {
    border-color: transparent;

    &:before,
    &:after {
	    box-shadow: 0 15px 12px rgba(31, 31, 31, 0.7);
    }
    &:before {
    	left: 10px;
    }
    &:after {
      right: 10px;
    }
  }
}

/* Flatten effect – flattens sides on hover */
.paper-flatten {
  border: 1px solid transparent;
	&:before,
	&:after {
		bottom: 15px;
     width: 50%;
     height: 20%;
     max-width: 300px;
     max-height: 100px;
    
     box-shadow: 0 15px 12px rgba(31, 31, 31, 0.7);
	}
  &:before {
    left: 10px;
    transform: rotate(-3deg);
	}
  &:after {
    right: 10px;
    transform: rotate(3deg);
	}
  
  &:hover {
    border-color: #ccc;
    
    &:before,
    &:after {
      transition: box-shadow 600ms ease-out, left 200ms, right 200ms;
	    box-shadow: 0 8px 8px rgba(31, 31, 31, 0.5);
    }
    &:before {
    	left: 5px;
    }
    &:after {
      right: 5px;
    }
  }
}


/* Curl effects – curls corners on hover */
.paper-curl,
.paper-curl-right {  
  &:before,
  &:after {
    bottom: 12px;
    width: 50%;
    height: 55%;
    max-width: 200px;
    max-height: 100px;
	 box-shadow: 1px 8px 12px rgba(31, 31, 31, 0.6);
  }
  &:before {
    left: 10px;
  }
  &:after {
    right: 10px;
  }
  
  &:hover {
    &:before,
    &:after {
      box-shadow: 1px 8px 12px rgba(31, 31, 31, 0.8);
    }
    &:before {
	    transform: skew(-8deg) rotate(-3deg);
    }
    &:after {
      transform: skew(8deg) rotate(3deg);
    }
  }
}
.paper-curl {
  &:hover {
    border-radius: 0 0 40% 40% / 0 0 30% 30%;
  }
}
.paper-curl-right {
  &:before {
    display: none;
  }
  
  &:hover {
    border-radius: 0 0 40% 0 / 0 0 30% 0;
	}
}

/* Curl effects – curls right hand side on hover */
.paper-curl-right-side {
  &:before,
  &:after {
    right: 10px;
    width: 50%;
    height: 55%;
    max-width: 200px;
    max-height: 100px;
  }
  &:before {
    top: 12px;
    box-shadow: 1px -4px 12px rgba(31, 31, 31, 0.6);
  }
  &:after {
    bottom: 12px;
    box-shadow: 1px 4px 12px rgba(31, 31, 31, 0.6);
  }
  &:hover {
    right: 0;
    border-radius: 0 3% 3% 0 / 0% 50% 50% 0;
    
    &:before {
      box-shadow: 10px -4px 12px rgba(31, 31, 31, 0.8);
	    transform: skew(-8deg) rotate(-3deg);
    }
    &:after {
      box-shadow: 10px 4px 12px rgba(31, 31, 31, 0.8);
      transform: skew(8deg) rotate(3deg);
    }
  }
}

.footerLink {
  position: absolute;
  bottom: 0;
  right: 0;
  padding: 10px 15px;
  
  color: #fff;
  background-color: rgba(0, 0, 0, 0.8);
  border-radius: 5px 0 0 0;
  text-decoration: none;
  transition: 300ms;
  
  &:hover {
    background-color: rgba(60, 60, 60, 0.8);
  }
}
            
          
!

JS

            
              
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console