zoukankan      html  css  js  c++  java
  • 2018.7.23 放大缩小菜单

    根据项目需求,展示隐藏侧边栏

    <html>
      <head>
        <title>最小化动画</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
      </head>
      <style>
        .wrap {
          position:relative;
          height:600px; 
        }
        .bigbox {
          400px; 
          height:600px; 
          background:gray; 
        }
        .box {
          position: absolute;
           50px;
          height: 50px;
          background: pink;
          bottom: 0;
          left: 418px;
          cursor: pointer;
        }
        button {
          float: right;
          margin-right: 16px;
          margin-top: 10px;
          cursor: pointer;
        }
        .minimum {
          -webkit-animation: change .5s ease-in-out 1 alternate forwards;
            animation: change .5s ease-in-out 1 alternate forwards;    
        }
        @-webkit-keyframes change {
          from {
            400px; 
            height:600px; 
          }
          to {
             50px;
            height: 50px;
            position: absolute;
            bottom: 0;
            left: 418px;
          }
        }
        @keyframes change {
          from {
            400px; 
            height:600px; 
            position: absolute;
            top: 0;
            left: 0;
          }
          to {
             0;
            height: 0;
            position: absolute;
            top: 0;
            left: 0;
          }
        }
        .maxmum {
          -webkit-animation: change-back .5s ease-in-out 1 alternate forwards;
            animation: change-back .5s ease-in-out 1 alternate forwards;    
        }
        @-webkit-keyframes change-back {
          from {
             50px;
            height: 50px;
            position: absolute;
            bottom: 0;
            left: 418px;
          }
          to {
            400px; 
            height:600px; 
          }
        }
        @keyframes change-back {
          from {
             0;
            height: 0;
            position: absolute;
            top: 0;
            left: 0;
          }    
          to {
            400px; 
            height:600px; 
            position: absolute;
            top: 0;
            left: 0;
          }
        }
      </style>
      <body>
          <div class="wrap">
              <div class="bigbox"> <button>最小化</button></div>    
              <div class="box"></div>
          </div>
      </body>
      <script type="text/javascript">
    
            document.getElementsByTagName("button")[0].onclick = function(){
                this.parentNode.classList.remove("maxmum");
                this.parentNode.classList.add("minimum");
            }
    
            document.getElementsByClassName("box")[0].onclick = function(){
              // document.getElementsByClassName("bigbox")[0].style.display = "block";
              document.getElementsByClassName("bigbox")[0].classList.remove("minimum");
              document.getElementsByClassName("bigbox")[0].classList.add("maxmum");
            }
          
      </script>
    </html>

    效果如下:

  • 相关阅读:
    操作标签(转载)
    创建标签(转载)
    标签管理(转载)
    mysql第四篇--SQL逻辑查询语句执行顺序
    mysql第四篇:数据操作
    mysql第四篇:数据操作之单表查询
    mysql第三篇:表操作
    MySQL系列
    Mysql 第二篇:库操作
    Mysql 第一篇:初识数据库
  • 原文地址:https://www.cnblogs.com/yuhanao/p/9354346.html
Copyright © 2011-2022 走看看