cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

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.

            
              <p>Fade Top</p>
<ul class="example01">
  <li><a href="#">menu01</a></li>
  <li><a href="#">menu02</a></li>
  <li><a href="#">menu03</a></li>
</ul>

<p>Fade Bottom</p>
<ul class="example02">
  <li><a href="#">menu01</a></li>
  <li><a href="#">menu02</a></li>
  <li><a href="#">menu03</a></li>
</ul>

<p>Left to Right</p>
<ul class="example03">
  <li><a href="#">menu01</a></li>
  <li><a href="#">menu02</a></li>
  <li><a href="#">menu03</a></li>
</ul>

<p>Right to Left</p>
<ul class="example04">
  <li><a href="#">menu01</a></li>
  <li><a href="#">menu02</a></li>
  <li><a href="#">menu03</a></li>
</ul>

<p>Left in Right</p>
<ul class="example05">
  <li><a href="#">menu01</a></li>
  <li><a href="#">menu02</a></li>
  <li><a href="#">menu03</a></li>
</ul>

<p>Right in Left</p>
<ul class="example06">
  <li><a href="#">menu01</a></li>
  <li><a href="#">menu02</a></li>
  <li><a href="#">menu03</a></li>
</ul>

<p>Center</p>
<ul class="example07">
  <li><a href="#">menu01</a></li>
  <li><a href="#">menu02</a></li>
  <li><a href="#">menu03</a></li>
</ul>
            
          
!
            
              body {
  margin: 5em 0 10em;
}
p {
  margin: 5em 0 1.5em;
  font-size: 28px;
  font-family: 'Open Sans', sans-serif;
  text-align: center;
}
ul {
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: center;
  li {
    display: inline-block;
    margin: 0 2em;
    a {
      color: #333;
      font-size: 18px;
      font-family: 'Open Sans', sans-serif;
      font-weight: 400;
    }
  }
}

// mixin
@mixin hover-underline($type: fade, $dir: null, $weight: 2px, $color: #000) {
  @if $dir == null {
    @if $type == fade {
      $dir: 'top';
    } @else if $type == slide {
      $dir: 'center';
    }
  }

  position: relative;
  display: inline-block;
  text-decoration: none;
  &::after {
    position: absolute;
    left: 0;
    content: '';
    width: 100%;
    height: $weight;
    background: $color;
    @if $type == fade {
      transition: .3s;
      opacity: 0;
      visibility: hidden;
      @if $dir == bottom {
        bottom: $weight * -4;
      } @else {
        bottom: $weight;
      }
    } @else if $type == slide {
      bottom: $weight * -2;
      transform: scale(0, 1);
      transition: transform .3s;
      @if $dir == left-right or $dir == right-in-left {
        transform-origin: left top;
      } @else if $dir == right-left or $dir == left-in-right {
        transform-origin: right top;
      } @else {
        transform-origin: center top;
      }
    }
  }
  &:hover::after {
    @if $type == fade {
      bottom: $weight * -2;
      opacity: 1;
      visibility: visible;
    } @else if $type == slide {
      @if $dir == left-in-right {
        transform-origin: left top;
      } @else if $dir == right-in-left {
        transform-origin: right top;
      }
      transform: scale(1, 1);
    }
  }
}

// usage
.example01 a {
  @include hover-underline('fade', 'top');
}
.example02 a {
  @include hover-underline('fade', 'bottom');
}
.example03 a {
  @include hover-underline('slide', 'left-right');
}
.example04 a {
  @include hover-underline('slide', 'right-left');
}
.example05 a {
  @include hover-underline('slide', 'left-in-right');
}
.example06 a {
  @include hover-underline('slide', 'right-in-left');
}
.example07 a {
  @include hover-underline('slide', 'center');
}
            
          
!
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