Эластичное горизонтальное меню на CSS3 и jQuery
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
.menu { position: relative; display: flex; flex-direction: row; justify-content: space-between; align-items: center; box-sizing: border-box; height: 70px; width: 70px; padding: 15px 20px; border-radius: 5px; background: #ffffff; box-shadow: 0 4px 64px rgba(0, 0, 0, 0.15); transition: 1.3s cubic-bezier(0.53, 0, 0.15, 1.3); z-index: 2; } .menu.expanded { height: 80px; width: 600px; } .menu span { white-space: nowrap; visibility: visible; opacity: 1; transition: .3s; transform: rotateY(0deg); } .menu span:nth-of-type(1) { transition-delay: .4s; } .menu span:nth-of-type(2) { transition-delay: .5s; } .menu span:nth-of-type(3) { transition-delay: .6s; } .menu span:nth-of-type(4) { transition-delay: .7s; } .menu span.hidden { width: 0; visibility: hidden; opacity: 0; transform: rotateY(90deg); } .menu span.hidden:nth-of-type(1) { transition-delay: .3s; } .menu span.hidden:nth-of-type(2) { transition-delay: .2s; } .menu span.hidden:nth-of-type(3) { transition-delay: .1s; } .menu span.hidden:nth-of-type(4) { transition-delay: 0s; } .menu a { text-decoration: none; text-transform: uppercase; font-weight: bold; color: #333333; padding: 5px; transition: .3s; } .menu a:hover { color: #D84315; } .container { order: 1; width: 20px; height: 24px; padding: 5px; display: flex; flex-direction: row; justify-content: space-between; align-items: center; cursor: pointer; } .container:hover .toggle:before { top: -9px; } .container:hover .toggle:after { bottom: -7px; } .container .toggle { position: relative; width: 100%; height: 2px; background: #aaaaaa; } .container .toggle:before { position: relative; display: flex; top: -7px; height: 2px; width: 100%; background: #aaaaaa; content: ""; transition: top .25s ease, bottom .25s ease, transform .5s ease; } .container .toggle:after { position: relative; display: flex; bottom: -5px; height: 2px; width: 100%; background: #aaaaaa; content: ""; transition: top .25s ease, bottom .25s ease, transform .25s ease; } .container .toggle.close { height: 0; } .container .toggle.close:before { transform: rotate(45deg); top: 0; } .container .toggle.close:after { transform: rotate(-45deg); bottom: 2px; } @keyframes respiration { 0% { min-height: 100vh; border: 0vh solid #ffffff; } 75% { min-height: 95vh; border: 2.5vh solid #ffffff; } 100% { min-height: 100vh; border: 0vh solid #ffffff; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<div class="menu expanded"> <div class="container close"> <div class="toggle close"></div> </div> <span class=""><a href="#">Home </a></span> <span class=""><a href="#">About</a></span> <span class=""><a href="#">Info</a></span> <span class=""><a href="#">Contact</a></span> </div> <script> $('.container').on('click', function() { $('.menu').toggleClass('expanded'); $('span').toggleClass('hidden'); $('.container, .toggle').toggleClass('close'); }); </script> |