Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">
  <h1>navigation</h1>
  
  <nav class="type1">
    <h2>type1</h2>
    <ul class="type1-menu">
      <li><a href="#">HOME</a></li>
      <li><a href="#">ABOUT</a></li>
      <li><a href="#">WORKS</a></li>
      <li><a href="#">CONTACT</a></li>
    </ul>
  </nav>
  
  <nav class="type2">
    <h2>type2</h2>
    <ul class="type2-menu">
      <li><a href="#">HOME</a></li>
      <li><a href="#">ABOUT</a></li>
      <li><a href="#">WORKS</a></li>
      <li><a href="#">CONTACT</a></li>
    </ul>
  </nav>
  
  <nav class="type3">
    <h2>type3</h2>
    <ul class="type3-menu">
      <li><a href="#">HOME</a></li>
      <li><a href="#">ABOUT</a></li>
      <li><a href="#">WORKS</a></li>
      <li><a href="#">CONTACT</a></li>
    </ul>
  </nav>
  
  <nav class="type4">
    <h2>type4</h2>
    <ul class="type4-menu">
      <li>
        <a href="#">
          <span class="en">HOME</span>
          <span class="ja">ホーム</span>
        </a>
      </li>
      <li>
        <a href="#">
          <span class="en">ABOUT</span>
          <span class="ja">ページについて</span>
        </a>
      </li>
      <li>
        <a href="#">
          <span class="en">WORKS</span>
          <span class="ja">作品</span>
        </a>
      </li>
      <li>
        <a href="#">
          <span class="en">CONTACT</span>
          <span class="ja">お問合わせ</span>
        </a>
      </li>
    </ul>
  </nav>
  
  <nav class="type5">
    <h2>type5</h2>
    <ul class="type5-menu">
      <li><a href="#">HOME</a></li>
      <li><a href="#">ABOUT</a></li>
      <li><a href="#">WORKS</a></li>
      <li><a href="#">CONTACT</a></li>
    </ul>
  </nav>
  
  <nav class="type6">
    <h2>type6</h2>
    <ul class="type6-menu">
      <li><a href="#">HOME</a></li>
      <li><a href="#">ABOUT</a></li>
      <li><a href="#">WORKS</a></li>
      <li><a href="#">CONTACT</a></li>
    </ul>
  </nav>
  
</div>
              
            
!

CSS

              
                $base-transition: all 0.2s cubic-bezier(0.455, 0.03, 0.515, 0.955);
body {
  background: #cccccc;
  font-family: Gill Sans;
  & > * ::selection {
    background: yellow;
  }
}
.container {
  width: 768px;
  margin: 50px auto;
  padding: 40px;
  box-sizing: border-box;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}
h1 {
  font-size: 30px;
  text-align: center;
  margin-bottom: 30px;
}
h2 {
  font-size: 14px;
  font-weight: bold;
  border-top: 1px solid #cccccc;
  padding-top: 30px;
  margin-bottom: 20px;
  text-indent: 10px;
}
nav {
  margin-bottom: 30px;
}

/*-----  共通スタイル -----*/
nav ul {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  li {
    margin-right: 1rem;
    a {
      display: block;
      padding: 10px;
      color: #000000;
      text-decoration: none;
    }
  }
}


/*-----  type1 -----*/
.type1 {
  .type1-menu {
    a {
      position: relative;
      &::after {
        position: absolute;
        left: 0;
        bottom: 0;
        display: block;
        content: "";
        width: 0%;
        height: 2px;
        background: #000;
        transition: $base-transition;
      }
      &:hover {
        &::after {
          width: 100%;
        }
      }
    }
  }
}


/*-----  type2 -----*/
.type2 {
  .type2-menu {
    a {
      position: relative;
      border-bottom: 2px solid #b2b2b2;
      &::after {
        position: absolute;
        bottom: -2px;
        left: 0;
        display: block;
        content: "";
        width: 100%;
        height: 2px;
        background: #000000;
        // transform: scaleX(0);
        transform-origin: right top;
        transition: transform 0.3s;
      }
      &:hover {
        &::after {
          // transform: scaleX(1);
          transform-origin: left top;
        }
      }
    }
  }
}


/*-----  type3 -----*/
.type3 {
  .type3-menu {
    a {
      position: relative;
      &::after {
        position: absolute;
        left: 0;
        top: 50%;
        bottom: 50%;
        transform: translate(0, -50%);
        display: block;
        content: "";
        width: 0%;
        height: 2px;
        background: #000000;
        transition: $base-transition;
      }
      &:hover {
        &::after {
          width: 100%;
        }
      }
    }
  }
}


/*-----  type4 -----*/
.type4 {
  .type4-menu {
    a {
      position: relative;
      text-align: center;
      overflow: hidden;
      padding: 10px 22px;
      span {
        display: block;
        width: 100%;
        margin: 0 auto;
        transition: $base-transition;
      }
      span.ja {
        position: absolute;
        top: 100%;
        left: 0%;
        font-size: 14px;
        font-weight: bold;
        white-space: nowrap;
        color: #F05152;
      }
      &::after {
        position: absolute;
        bottom: 0;
        left: 0;
        display: block;
        content: "";
        width: 0%;
        height: 2px;
        background: #F05152;
        transition: $base-transition;
      }
      &:hover {
        span.en {
          transform: translate(0%, -150%);
        }
        span.ja {
          top: 25%;
        }
        &::after {
          width: 100%;
        }
      }
    }
  }
}


/*-----  type5 -----*/
.type5 {
  .type5-menu {
    li {
      position: relative;
      overflow: hidden;
      &::before,
      &::after {
        position: absolute;
        display: block;
        content: "";
        width: 100%;
        height: 1px;
        background: #000000;
        transition: $base-transition;
      }
      &::before {
        top: 0;
        left: -100%;
      }
      &::after {
        bottom: 0;
        right: -100%
      }
    }
    a {
      &::before,
      &::after {
        position: absolute;
        display: block;
        content: "";
        width: 1px;
        height: 100%;
        background: #000000;
        transition: $base-transition;
      }
      &::before {
        top: 100%;
        left: 0;
      }
      &::after {
        top: -100%;
        right: 0;
      }
    }
    li:hover {
      &::before {
        left: 0;
      }
      &::after {
        right: 0;
      }
      a {
        &::before {
          top: 0;
        }
        &::after {
          top: 0;
        }
      }
    }
  }
}


/*-----  type6 -----*/
.type6 {
  .type6-menu {
    li {
      position: relative;
      overflow: hidden;
      &::before,
      &::after {
        position: absolute;
        display: block;
        content: "";
        width: 100%;
        height: 1px;
        background: #000000;
        transition: $base-transition;
      }
      &::before {
        top: 0;
        left: -100%;
      }
      &::after {
        bottom: 0;
        right: -100%
      }
    }
    a {
      &::before,
      &::after {
        position: absolute;
        display: block;
        content: "";
        width: 1px;
        height: 100%;
        background: #000000;
        transition: $base-transition;
      }
      &::before {
        top: 100%;
        left: 0;
      }
      &::after {
        top: -100%;
        right: 0;
      }
    }
    li:hover {
      &::before {
        animation: topline 0.1s linear forwards;
      }
      @keyframes topline {
        0% {
          left: -100%;
        }
        100% {
          left: 0;
        }
      }
      &::after {
        animation: btmline 0.1s linear forwards 0.2s;
      }
      @keyframes btmline {
        0% {
          right: -100%
        }
        100% {
          right: 0;
        }
      }
      a {
        &::before {
          animation: leftline 0.1s linear forwards 0.3s;
        }
        @keyframes leftline {
          0% {
            top: 100%;
          }
          100% {
            top: 0;
          }
        }
        &::after {
          animation: rightline 0.1s linear forwards 0.1s;
        }
        @keyframes rightline {
          0% {
            top: -100%;
          }
          100% {
            top: 0;
          }
        }
      }
    }
  }
}
              
            
!

JS

              
                /*--------------------

codepen上でtype2のアニメーションが正常に動きませんが、
type2内のtransformのコメントアウトを外せば
ご使用いただけます。

--------------------*/
              
            
!
999px

Console