cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmloctocatspinnerstartv

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

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

Code Indentation

     

Save Automatically?

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

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="centerer">
  <h1>Just Some More</h1>
  <h1>Button Hover Effects</h1>
  <h4>By: <a href="http://kylebrumm.com" target="_blank">Kyle Brumm</a></h4>

  <div class="wrap">
    <a class="btn-0" href="#">Swipe</a>
    <a class="btn-1" href="#">Diagonal Swipe</a>
    <a class="btn-1-2" href="#">Double Swipe</a>
    <a class="btn-2" href="#">Diagonal Close</a>
    <a class="btn-3" href="#"><span>Zoning In</span></a>
    <a class="btn-4" href="#"><span>4 Corners</span></a>
    <a class="btn-5" href="#">Slice</a>
  </div>
  <div class="wrap">
    <a class="btn-6" href="#">Position Aware<span></span></a>
    <a class="btn-7" href="#"><span>Alternate</span></a>
    <a class="btn-8" href="#">Smoosh</a>
    <a class="btn-9" href="#"><span>Vertical Overlap</span></a>
    <a class="btn-10" href="#"><span>Horizontal Overlap</span></a>
    <a class="btn-11" href="#">Collision</a>
  </div>
</div>
            
          
!
            
              @import url(http://fonts.googleapis.com/css?family=Open+Sans:400|Raleway:300);

$btn-width: 250px !default;
$btn-height: 80px !default;
$btn-full: $btn-height+$btn-width !default;
$btn-half: $btn-full/2 !default;
$bg-color: #eeeeee !default;

html {
  padding-top: 50px;
  font-family: 'Open Sans', Helvetica, arial, sans-serif;
  text-align: center;
  background-color: $bg-color;

  *,
  *:before,
  *:after {
    box-sizing: border-box;
    transition: 0.5s;
  }

  i,em,
  b,strong,
  span {
    transition: none;
  }
}

*:before,
*:after {
  z-index: -1;
}

h1,
h4 {
  font-family: 'Raleway', 'Open Sans', sans-serif;
  margin: 0;
  line-height: 1;
}

a {
  text-decoration: none;
  line-height: $btn-height;
  color: black;
}

.centerer {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 1rem
}

@media (min-width: 600px) {
  .wrap {
    width: 50%;
    float: left;
  }
}

[class^="btn-"] {
  position: relative;
  display: block;
  margin: 1rem auto;
  @include size(100%, $btn-height);
  max-width: $btn-width;
  text-transform: uppercase;
  overflow: hidden;
  border: 1px solid currentColor;
}

.btn-0 {
  $btn-color: random-color($max:200);
  $btn-color-dark: shade($btn-color, 40%);
  color: tint($btn-color);

  &:before {
    content: '';
    @include absolute(0,null,null,0);
    @include size(0, $btn-height);
    background: $btn-color-dark;
  }

  &:hover {
    color: tint($btn-color, 75%);

    &:before {
      width: $btn-width;
    }
  }

  &:active {
    background: $btn-color;
  }
}

.btn-1 {
  $btn-color: random-color($max:200);
  $btn-color-dark: shade($btn-color, 40%);
  color: tint($btn-color);
  @include triangle(up-left, 0, $btn-color-dark, true);

  &:hover {
    color: tint($btn-color, 75%);

    &:after {
      border-width: $btn-full $btn-full 0 0;
    }
  }

  &:active {
    background: $btn-color;
  }
}

.btn-1-2 {
  $btn-color: random-color($max:200);
  $btn-color-dark: shade($btn-color, 40%);
  color: tint($btn-color);
  @include triangle(down-left, 0, $btn-color-dark, true, before);
  @include triangle(down-right, 0, $btn-color-dark, true);

  &:hover {
    color: tint($btn-color, 75%);

    &:before {
      border-width: $btn-half*1.25 0 0 $btn-half*1.25;
    }

    &:after {
      border-width: 0 0 $btn-half*1.25 $btn-half*1.25;
    }
  }

  &:active {
    background: $btn-color;
  }
}

.btn-2 {
  $btn-color: random-color($max:200);
  $btn-color-dark: shade($btn-color, 40%);
  color: tint($btn-color);
  @include triangle(down-left, 0, $btn-color-dark, true, before);
  @include triangle(up-right, 0, $btn-color-dark, true);

  &:hover {
    color: tint($btn-color, 75%);
    
    &:before {
      border-width: $btn-half 0 0 $btn-half;
    }
    
    &:after {
      border-width: 0 $btn-half $btn-half 0;
    }
  }
  
  &:active {
    background: $btn-color;
  }
}

.btn-3 {
  $btn-color: random-color($max:200);
  $btn-color-dark: shade($btn-color, 40%);
  @include triangle(down-left, 0, $btn-color-dark, true, before);
  @include triangle(up-right, 0, $btn-color-dark, true);
  color: tint($btn-color);
  
  span {
    @include triangle(down-right, 0, $btn-color-dark, true, before);
    @include triangle(up-left, 0, $btn-color-dark, true);
  }
  
  &:hover {
    color: tint($btn-color, 75%);
    
    &:before {
      border-width: $btn-half 0 0 $btn-half;
    }
    
    &:after {
      border-width: 0 $btn-half $btn-half 0;
    }
    
    span {
      &:before {
        border-width: 0 0 $btn-half $btn-half;
      }
      
      &:after {
        border-width: $btn-half $btn-half 0 0;
      }
    }
  }
  
  &:active {
    background: $btn-color;
  }
}

.btn-4 {
  $btn-color: random-color($max:200);
  $btn-color-dark: shade($btn-color, 40%);
  @include triangle(up-right, 0, $btn-color-dark, true);
  @include triangle(down-left, 0, $btn-color-dark, true, before);
  color: tint($btn-color);
  
  &:before,
  &:after {
    border-color: $btn-color-dark;
  }
  
  span {
    @include triangle(up-left, 0, $btn-color-dark, true);
    @include triangle(down-right, 0, $btn-color-dark, true, before);
    
    &:before,
    &:after {
      border-color: $btn-color-dark;
    }
  }
  
  &:hover {
    color: tint($btn-color, 75%);
    
    &:before {
      border-width: $btn-height/4 $btn-width/4;
    }
    
    &:after {
      border-width: $btn-height/4 $btn-width/4;
    }
    
    span {
      &:before {
        border-width: $btn-height/4 $btn-width/4;
      }
      
      &:after {
        border-width: $btn-height/4 $btn-width/4;
      }
    }
  }
  
  &:active {
    background: $btn-color;
  }
}

.btn-5 {
  $btn-color: random-color($max:200);
  $btn-color-dark: shade($btn-color, 40%);
	color: tint($btn-color);
  @include triangle(up-right, 0, $btn-color-dark, true);
  @include triangle(down-left, 0, $btn-color-dark, true, before);
  
  &:hover {
    color: tint($btn-color, 75%);
    
    &:before,
    &:after {
      border-width: $btn-height $btn-width*1.05;
    }
  }
  
  &:active {
    background: $btn-color;
  }
}

.btn-6 {
  $btn-color: random-color($max:200);
  $btn-color-dark: shade($btn-color, 40%);
	color: tint($btn-color);
  
  span {
    position: absolute;
    display: block;
    @include size(0);
    border-radius: 50%;
    background: $btn-color-dark;
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
    z-index: -1;
  }
  
  &:hover {
    color: tint($btn-color, 75%);
    
    span {
      @include size($btn-width*2.25);
    }
  }
  
  &:active {
    background: $btn-color;
  }
}

.btn-7 {
  $btn-color: random-color($max:200);
  $btn-color-dark: shade($btn-color, 40%);
  color: tint($btn-color);
  
  &:before,
  &:after,
  span:before,
  span:after {
    content: '';
    @include absolute(0);
    @include size($btn-width/4 + 1px, 0);
    background: $btn-color-dark;
  }
  
  &:before {
    left: 0;
  }
  
  &:after {
    left: $btn-width/2;
  }
  
  span {
    &:before,
    &:after {
      top: auto;
      bottom: 0;
    }
    
    &:before {
      left: $btn-width/4;
    }
    
    &:after {
      left: $btn-width - $btn-width/4;
    }
  }
  
  &:hover {
    color: tint($btn-color, 75%);
    
    &:before,
    &:after,
    span:before,
    span:after {
      height: $btn-height;
    }
  }
  
  &:active {
    background: $btn-color;
  }
}

.btn-8 {
  $btn-color: random-color($max:200);
  $btn-color-dark: shade($btn-color, 40%);
  color: tint($btn-color);
  
  &:before,
  &:after {
    content: '';
    @include absolute(0,null,null,0);
    @include size($btn-width, 0);
    background: $btn-color-dark;
  }
  
  &:after {
    top: auto;
    bottom: 0;
  }
  
  &:hover {
    color: tint($btn-color, 75%);
    
    &:before,
    &:after {
      height: $btn-height/2;
    }
  }
  
  &:active {
    background: $btn-color;
  }
}

.btn-9 {
  $btn-color: random-color($max:200);
  $btn-color-dark: shade($btn-color, 40%);
  color: tint($btn-color);
  
  &:before,
  &:after,
  span:before,
  span:after {
    content: '';
    @include absolute(0,null,null,0);
    @include size($btn-width, 0);
    background: rgba($btn-color-dark, 0.25);
    transition: 0.4s;
  }
  
  &:after,
  span:before {
    top: auto;
    bottom: 0;
  }
  
  span:before,
  span:after {
    transition-delay: 0.4s;
  }
  
  &:hover {
    color: tint($btn-color, 75%);
    
    &:before,
    &:after,
    span:before,
    span:after {
      height: $btn-height;
    }
  }
  
  &:active {
    background: $btn-color;
  }
}

.btn-10 {
  $btn-color: random-color($max:200);
  $btn-color-dark: shade($btn-color, 40%);
  color: tint($btn-color);
  
  &:before,
  &:after,
  span:before,
  span:after {
    content: '';
    @include absolute(0,null,null,0);
    @include size(0, $btn-height);
    background: rgba($btn-color-dark, 0.25);
    transition: 0.4s;
  }
  
  &:after,
  span:before {
    left: auto;
    right: 0;
  }
  
  span:before,
  span:after {
    transition-delay: 0.4s;
  }
  
  &:hover {
    color: tint($btn-color, 75%);
    
    &:before,
    &:after,
    span:before,
    span:after {
      width: $btn-width;
    }
  }
  
  &:active {
    background: $btn-color;
  }
}

@keyframes criss-cross-left {
  0% {
    left: -20px;
  }
  50% {
    left: 50%;
    @include size(20px);
  }
  100% {
    left: 50%;
    @include size($btn-width*1.5);
  }
}

@keyframes criss-cross-right {
  0% {
    right: -20px;
  }
  50% {
    right: 50%;
    @include size(20px);
  }
  100% {
    right: 50%;
    @include size($btn-width*1.5);
  }
}

.btn-11 {
  position: relative;
  $btn-color: random-color($max:200);
  $btn-color-dark: shade($btn-color, 40%);
  color: tint($btn-color);
  
  &:before,
  &:after {
    @include absolute(50%);
    content: '';
    @include size(20px);
    background: $btn-color;
    border-radius: 50%;
  }
  
  &:before {
    left: -20px;
    transform: translate(-50%, -50%);
    // animation: criss-cross-left 0.8s reverse;
  }
  
  &:after {
    right: -20px;
    transform: translate(50%, -50%);
    // animation: criss-cross-right 0.8s reverse;
  }
  
  &:hover {
    color: tint($btn-color, 75%);

    &:before,
    &:after {
      // @include size($btn-width);
    }
    
    &:before {
      animation: criss-cross-left 0.8s both;
    }
    
    &:after {
      animation: criss-cross-right 0.8s both;
    }
  }
}
            
          
!
            
              $(function() {  
  $('.btn-6')
    .on('mouseenter', function(e) {
			var parentOffset = $(this).offset(),
      		relX = e.pageX - parentOffset.left,
      		relY = e.pageY - parentOffset.top;
			$(this).find('span').css({top:relY, left:relX})
    })
    .on('mouseout', function(e) {
			var parentOffset = $(this).offset(),
      		relX = e.pageX - parentOffset.left,
      		relY = e.pageY - parentOffset.top;
    	$(this).find('span').css({top:relY, left:relX})
    });
  $('[href=#]').click(function(){return false});
});
            
          
!
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