A Pen by Elitsa Dimitrova on CodePen.
Created
February 20, 2020 16:06
-
-
Save nraloux/e5472f231baa03fb2e6cbbf9eabd2a19 to your computer and use it in GitHub Desktop.
CSS Challenge - Day 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="box"> | |
| <div class="btn not-active"> | |
| <span></span> | |
| <span></span> | |
| <span></span> | |
| </div> | |
| </div> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var btn = $('.btn'); | |
| btn.on('click', function() { | |
| $(this).toggleClass('active'); | |
| $(this).toggleClass('not-active'); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| green: #3FAF82 | |
| */ | |
| .box { | |
| border-radius: 2px; | |
| position: absolute; | |
| top: 50%; | |
| left: 50%; | |
| transform: translate(-50%, -50%); | |
| width: 400px; | |
| height: 400px; | |
| background: #3faf82; | |
| box-shadow: 1px 2px 10px 0px rgba(0,0,0,0.3); | |
| } | |
| .btn { | |
| position: absolute; | |
| top: 50%; | |
| left: 50%; | |
| transform: translate(-50%, -50%); | |
| width: 80px; | |
| cursor: pointer; | |
| } | |
| span { | |
| display: block; | |
| width: 100%; | |
| box-shadow: 0 2px 10px 0 rgba(0,0,0,0.3); | |
| border-radius: 3px; | |
| height: 8px; | |
| background: #fff; | |
| transition: all .3s; | |
| position: relative; | |
| } | |
| span + span { | |
| margin-top: 14px; | |
| } | |
| .active span:nth-child(1) { | |
| animation: ease .7s top forwards; | |
| } | |
| .not-active span:nth-child(1) { | |
| animation: ease .7s top-2 forwards; | |
| } | |
| .active span:nth-child(2) { | |
| animation: ease .7s scaled forwards; | |
| } | |
| .not-active span:nth-child(2) { | |
| animation: ease .7s scaled-2 forwards; | |
| } | |
| .active span:nth-child(3) { | |
| animation: ease .7s bottom forwards; | |
| } | |
| .not-active span:nth-child(3) { | |
| animation: ease .7s bottom-2 forwards; | |
| } | |
| @keyframes top { | |
| 0% { | |
| top: 0; | |
| transform: rotate(0); | |
| } | |
| 50% { | |
| top: 22px; | |
| transform: rotate(0); | |
| } | |
| 100% { | |
| top: 22px; | |
| transform: rotate(45deg); | |
| } | |
| } | |
| @keyframes top-2 { | |
| 0% { | |
| top: 22px; | |
| transform: rotate(45deg); | |
| } | |
| 50% { | |
| top: 22px; | |
| transform: rotate(0deg); | |
| } | |
| 100% { | |
| top: 0; | |
| transform: rotate(0deg); | |
| } | |
| } | |
| @keyframes bottom { | |
| 0% { | |
| bottom: 0; | |
| transform: rotate(0); | |
| } | |
| 50% { | |
| bottom: 22px; | |
| transform: rotate(0); | |
| } | |
| 100% { | |
| bottom: 22px; | |
| transform: rotate(135deg); | |
| } | |
| } | |
| @keyframes bottom-2 { | |
| 0% { | |
| bottom: 22px; | |
| transform: rotate(135deg); | |
| } | |
| 50% { | |
| bottom: 22px; | |
| transform: rotate(0); | |
| } | |
| 100% { | |
| bottom: 0; | |
| transform: rotate(0); | |
| } | |
| } | |
| @keyframes scaled { | |
| 50% { | |
| transform: scale(0); | |
| } | |
| 100% { | |
| transform: scale(0); | |
| } | |
| } | |
| @keyframes scaled-2 { | |
| 0% { | |
| transform: scale(0); | |
| } | |
| 50% { | |
| transform: scale(0); | |
| } | |
| 100% { | |
| transform: scale(1); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment