Skip to content

Instantly share code, notes, and snippets.

@mtmr0x
Created September 27, 2018 11:43
Show Gist options
  • Select an option

  • Save mtmr0x/4e1ecf553d18e11ca1aedf1cd2bdba1e to your computer and use it in GitHub Desktop.

Select an option

Save mtmr0x/4e1ecf553d18e11ca1aedf1cd2bdba1e to your computer and use it in GitHub Desktop.
Botão animado - CSS Meetup
<!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>
@netojocelino
Copy link

Esse if poderia trocar por btn.classList.toggle("loading")

@rogerramosme
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment