Skip to content

Instantly share code, notes, and snippets.

@Oluwa-nifemi
Created March 29, 2020 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Oluwa-nifemi/c3843a23978d2ee53e5a57826c6368ea to your computer and use it in GitHub Desktop.
Save Oluwa-nifemi/c3843a23978d2ee53e5a57826c6368ea to your computer and use it in GitHub Desktop.
CSS to add a rotating loader inside a button with minimal css
input[type=submit].loading{
color: transparent;
position: relative;
}
input[type=submit].loading::before{
width: 20px;
height: 20px;
border: 2px solid #e1e1e1;
border-top-color: #898989;
animation: rotate 0.6s linear infinite;
content: '';
position: absolute;
border-radius: 50%;
right: calc(50% - 10px);
}
@keyframes rotate {
from{
transform: rotate(0);
}
to{
transform: rotate(360deg);
}
}
document.querySelector('input[type=submit]').addEventListener('click', () => {
document.querySelector('input[type=submit]').classList.add('loading')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment