text 导航按钮动画

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text 导航按钮动画相关的知识,希望对你有一定的参考价值。

<button class="nav__toggle ex__01">
  <span></span>
  <span></span>
  <span></span>
  <span></span>
</button>

<button class="nav__toggle ex__02">
  <span></span>
  <span></span>
  <span></span>
  <span></span>
</button>

<button class="nav__toggle ex__03">
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
</button>
.nav__toggle {
  outline: none;
  border: 3px solid black;
  background: white;
  height: 100px;
  width: 100px;
  display: inline-block;
  margin-top: 30px;
  margin-left: 100px;
  position: relative;
  padding: 10px;
  span {
    height: 6px;
    width: 70px;
    display: inline-block;
    background: black;
    position: absolute;
    left: 0;
    right: 0;
    margin: 0 auto;
    transition: transform 0.3s ease, opacity 0.3s ease;
    &:nth-child(1) {
      top: 30px;
    }
    &:nth-child(2),
    &:nth-child(3) {
      top: 45px;
    }
    &:nth-child(4) {
      top: 60px;
    }
  }
}

// EXAMPLE 01
.ex__01 {
  span {
    transition: transform 0.3s ease, opacity 0.2s ease;
  }
  &.open {
    span {
      &:nth-child(1),
      &:nth-child(4){
        opacity: 0;
      }
      &:nth-child(2) {
        transform: rotate(-45deg);
      }
      &:nth-child(3) {
        transform: rotate(45deg);
      }
    }
  }
}

// EXAMPLE 02
.ex__02 {
  span {
    width: 70px;
    transition: transform 0.3s ease, width 0.5s ease;
    &:nth-child(4){
      left: 11px;
      right: auto;
      transition-delay: 0s;
    }
    &:nth-child(1){
      right: 11px;
      left: auto;
      transition-delay: 0s;
    }
    &:nth-child(2),
    &:nth-child(3){
      transition-delay: 0.3s;
    }
  }
  &.open {
    span {
      &:nth-child(1),
      &:nth-child(4){
        width: 0px;
        transition-delay: 0.2s;
      }
      &:nth-child(2) {
        transform: rotate(-45deg);
        transition-delay: 0s;
      }
      &:nth-child(3) {
        transform: rotate(45deg);
        //transition-delay: 0s;
      }
    }
  }
}

// EXAMPLE 03
.ex__03 {
  overflow: hidden;
  span {
    &:nth-child(3){
      top: 60px;
    }
    &:nth-child(5),
    &:nth-child(6){
      top: 150px;
    }
    &:nth-child(5) {
        transform: rotate(-45deg);
    }
    &:nth-child(6) {
        transform: rotate(45deg);
    }
  }
  &.open {
    span {
      &:nth-child(1),
      &:nth-child(2),
      &:nth-child(3),
      &:nth-child(4){
        transform: translateY(-105px);
      }
      &:nth-child(5) {
        transform: translateY(-105px) rotate(-45deg);
      }
      &:nth-child(6) {
        transform: translateY(-105px) rotate(45deg);
      }
    }
  }
}
$(document).ready(function(){
  $('.nav__toggle').on('click', function(){
     $(this).toggleClass('open');
  });
});
View Pen:

http://codepen.io/DinosVsRobots/pen/ZLbRBL


More animations to be added

以上是关于text 导航按钮动画的主要内容,如果未能解决你的问题,请参考以下文章

导航控制器中的后退按钮动画

导航栏按钮动画错误

Android Compose 新闻App导航动画WebView浮动按钮底部导航

Android Compose 新闻App导航动画WebView浮动按钮底部导航

基于导航的应用程序的翻转动画

导航“后退”按钮暂停,以便在弹出之前做一个快速动画