美文网首页CSS小技巧前端前端
Vue<3D旋转导航栏效果>

Vue<3D旋转导航栏效果>

作者: 誰在花里胡哨 | 来源:发表于2019-12-13 18:11 被阅读0次
    效果图:
    hover.gif
    简单的css+html效果 🐷
    代码如下:
    <template>
      <div class="overall">
        <ul>
          <li>
            <section class="nav-z">
              <span class="nav">
                <span class="title">HOVER</span>
              </span>
            </section>
            <section class="nav-f">
              <span class="nav">
                <span class="title">HOVER</span>
              </span>
            </section>
          </li>
        </ul>
      </div>
    </template>
    
    <script>
    export default {};
    </script>
    
    <style lang="scss" scoped>
    ul {
      background: rgb(128, 128, 128);
      list-style: none;
      padding: 0;
      li {
        overflow: hidden;
        perspective: 500px;
        cursor: pointer;
        user-select: none;
        display: block;
        width: 150px;
        height: 60px;
        color: #808080;
        position: relative;
        display: flex;
        justify-content: center;
        align-items: center;
        &:hover .nav-z {
          top: -60px;
          transform: rotateX(90deg);
        }
        &:hover .nav-f {
          z-index: 5;
          top: 0;
          transform: rotateX(0deg);
        }
        section {
          transition: 0.3s;
          width: 100%;
          height: 100%;
          display: flex;
          justify-content: center;
          align-items: center;
          transform-style: preserve-3d;
          position: absolute;
          left: 0;
          top: 0;
        }
        .nav-z {
          transform-origin: 50% 100%;
          background: white;
          top: 0;
          z-index: 5;
          color: black;
          font-weight: bold;
        }
        .nav-f {
          transform-origin: 50% 0%;
          background: black;
          transform: rotateX(-90deg);
          top: 60px;
          color: white;
          font-weight: bold;
        }
      }
    }
    </style>
    

    相关文章

      网友评论

        本文标题:Vue<3D旋转导航栏效果>

        本文链接:https://www.haomeiwen.com/subject/excqnctx.html