Forked from Captain Anonymous's Pen qdxzjL.
A Pen by Alexander Belov on CodePen.
| #button.block | |
| .wrapper | |
| .line.first | |
| .line.second | |
| .line.third |
Forked from Captain Anonymous's Pen qdxzjL.
A Pen by Alexander Belov on CodePen.
| $(document).ready(function() { | |
| $('#button').on('click', function(e) { | |
| if ($(this).hasClass('opened')) { | |
| $(this).removeClass('opened') | |
| } else { | |
| $(this).addClass('opened') | |
| } | |
| }); | |
| }); |
| <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
| body { | |
| width: 100px; | |
| margin: auto; | |
| padding: 100px; | |
| } | |
| .block { | |
| width: 48px; | |
| height: 48px; | |
| background: #FF6666; | |
| border-radius: 2px; | |
| padding: 12px; | |
| box-sizing: border-box; | |
| cursor: pointer; | |
| } | |
| .wrapper { | |
| height: 100%; | |
| width: 100%; | |
| position: relative; | |
| overflow: hidden; | |
| } | |
| .line { | |
| height: 3px; | |
| background: #fff; | |
| position: absolute; | |
| width: 100%; | |
| transition: top .1s ease-in, transform .1s ease-in .1s; | |
| } | |
| .line.first { | |
| top: 3px; | |
| } | |
| .line.second { | |
| top: 10px; | |
| transition: all .2s ease-in; | |
| right: 0; | |
| } | |
| .line.third { | |
| top: 17px; | |
| } | |
| .opened .line.first { | |
| top: 10px; | |
| transform: rotate(45deg); | |
| } | |
| .opened .line.third { | |
| top: 10px; | |
| transform: rotate(-45deg); | |
| } | |
| .opened .line.second { | |
| right: 40px; | |
| } | |
| .block:hover:not(.opened) .line.second { | |
| opacity: 0.8; | |
| } |