Created
September 27, 2018 11:43
-
-
Save mtmr0x/4e1ecf553d18e11ca1aedf1cd2bdba1e to your computer and use it in GitHub Desktop.
Botão animado - CSS Meetup
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <style> | |
| .btn { | |
| will-change: transform; | |
| border-radius: 3px; | |
| transition: all .1s ease-in-out; | |
| height: 29px; | |
| padding: 8px 32px; | |
| background: #52b8f9; | |
| border: 0; | |
| color: white; | |
| outline: none; | |
| } | |
| .btn.loading { | |
| animation: Rotate 1s linear infinite; | |
| width: 29px; | |
| height: 29px; | |
| padding: 0; | |
| background: transparent; | |
| border: 2px solid #52b8f9; | |
| border-bottom-color: transparent; | |
| color: transparent; | |
| border-radius: 50%; | |
| } | |
| @keyframes Rotate { | |
| to { | |
| transform: rotate(360deg); | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <button onclick="click" class="btn">Enviar</button> | |
| <script> | |
| var btn = document.querySelector('.btn'); | |
| btn.onclick = function() { | |
| if (btn.classList.contains('loading')) { | |
| return btn.classList.remove('loading'); | |
| } | |
| return btn.classList.add('loading'); | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Esse if poderia trocar por btn.classList.toggle("loading")