A Pen by Hưng Nguyễn on CodePen.
Created
January 30, 2022 05:36
-
-
Save RubanDurai/a233086ec519737626e008eb5ad485c3 to your computer and use it in GitHub Desktop.
Animated download button
This file contains 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
<h1>Animated download button</h1> | |
<h3>By ZeroX</h3> | |
<div class="btn"> | |
<span>Download</span> | |
</div> | |
<div class="bar"> | |
<div class="p"></div> | |
</div> |
This file contains 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
/* | |
Download button made by ZeroX | |
*/ | |
$(".btn").click(function(){ /*When user click the button*/ | |
$("span").fadeOut(); /*Fadeout the download span*/ | |
$(".btn").animate({ | |
width: "50px", /*Animate the width*/ | |
},function(){ | |
$(".btn").animate({ | |
top: "40%", | |
},function(){ | |
$(".bar").css("display","block"); | |
$(".btn").html('<i class="fa fa-ellipsis-h" aria-hidden="true"></i>'); | |
$(".p").animate({width:"100%"},2000,function(){ | |
$(".btn").html('<i class="fa fa-check" aria-hidden="true"></i>'); | |
$(".bar").fadeOut(); | |
$(".btn").animate({top:"50%"},function(){ | |
$(".btn").animate({width:"150px"},function(){ | |
$(".btn").html("<span>Download</span>"); | |
$(".p").css("width","0%"); | |
}) | |
}); | |
}); | |
}) | |
}); | |
}); |
This file contains 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://code.jquery.com/jquery-3.1.0.js"></script> |
This file contains 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
*{ | |
box-sizing: border-box; | |
} | |
html{ | |
background-color: lighten(black,20%); | |
h1,h3{ | |
color: white; | |
} | |
text-align: center; | |
} | |
.btn{ | |
width: 150px; | |
height: 50px; | |
background-color: $fRed; | |
color: white; | |
border-radius: 30px; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
font-family: "Raleway"; | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%,-50%); | |
cursor: pointer; | |
/*border: 2px solid $fWhite;*/ | |
transition: background-color 0.5s; | |
&:hover{ | |
background-color: $fWhite; | |
color: $fRed; | |
} | |
} | |
.bar{ | |
width: 200px; | |
height: 8px; | |
border-radius: 8px; | |
background-color: $fBlack; | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%,-50%); | |
display: none; | |
.p{ | |
width: 0%; | |
border-radius: 8px; | |
height: 100%; | |
background-color: $fRed; | |
} | |
} |
This file contains 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
<link href="https://raw.githubusercontent.com/ZeroX-DG/style-helper/master/scss/_FlatColors.scss" rel="stylesheet" /> | |
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" /> | |
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment