• css3 javascript 实现菜单按钮特效


    一个菜单按钮特效案例,简单的实现了动态效果。

    代码效果预览地址:

    http://code.w3ctech.com/detail/2504

    <div class="bar" id="menubar">
    
      <div class="menu" id="menu0">
    
      </div>
      <div class="menu" id="menu1">
    
      </div>
      <div class="menu" id="menu2">
    
      </div>
    </div>
     1 .bar{
     2             width:40px;
     3             height:40px;
     4             border:1px solid #ccc;
     5             border-radius:50%;
     6             position:fixed;
     7             top:10px;
     8             right:25px;
     9             z-index:1000;
    10             cursor:pointer;
    11         }
    12         .menu{
    13             width:20px;
    14             height:2px;
    15             background-color:#ccc;
    16             position:absolute;
    17             transform:translate3d(-50%,-50%,0);
    18             left:50%;
    19             transition:all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0s
    20         }
    21         #menu0{
    22             top:30%;
    23         }
    24         #menu1{
    25             top:50%;
    26         }
    27         #menu2{
    28             top:70%;
    29         }
     1 window.onload = function () {
     2             var menubar = document.getElementById("menubar");
     3             var menu0 = document.getElementById("menu0");
     4             var menu1 = document.getElementById("menu1");
     5             var menu2 = document.getElementById("menu2");
     6             var i = 0;
     7             menubar.onclick = function () {
     8                 i++;
     9                 if (i % 2 == 1) {
    10                     menu0.style.top = 50 + "%";
    11                     menu1.style.display = "none";
    12                     menu2.style.top = 50 + "%";
    13                     menu0.style.transform = "translate3d(-50%,-50%,0) rotate(135deg)";
    14                     menu2.style.transform = "translate3d(-50%,-50%,0) rotate(405deg)";
    15                 }
    16                 else {
    17                     menu0.style.transform = "translate3d(-50%,-50%,0) rotate(0deg)";
    18                     menu2.style.transform = "translate3d(-50%,-50%,0) rotate(0deg)";
    19                     menu0.style.top = 30 + "%";
    20                     menu2.style.top = 70 + "%";
    21                     menu1.style.display = "block";
    22                 }
    23             }
    24 
    25         }
  • 相关阅读:
    Fibonacci Again
    N的10000的阶乘
    HDU2141(二分搜索)
    POJ2366(HASH法)
    10106 Product
    UVA 401 Palindromes
    UVA424 Integer Inquiry
    POJ2503(二分搜索)
    mysql重置root密码
    tidb安装haproxy负载均衡
  • 原文地址:https://www.cnblogs.com/younth/p/5183412.html
Copyright © 2020-2023  润新知