CSS Processing Button

Developer
Size
3,605 Kb
Views
4,048

How do I make an css processing button?

Nothing special, just a css button with a processing, success and error state. What is a css processing button? How do you make a css processing button? This script and codes were developed by Stephen Fray on 20 January 2023, Friday.

CSS Processing Button Previews

CSS Processing Button - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>CSS Processing Button</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <a class="btn p" href="#">Submit</a>
<div class="f success">Fake Success State</div>
<div class="f error">Fake Error State</div>
<div class="f reset">Reset</div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

CSS Processing Button - Script Codes CSS Codes

body { font-family: arial;
}
.f { margin: 20px 0 0; cursor: pointer; background-color: #ccc; padding: 10px 20px; display: inline-block; clear: both; transition: all 0.2s ease-in; float: left;
}
.f:hover { background-color: #333; color: #fff;
}
.f:first-of-type { margin: 50px 0 0;
}
.btn { background-color: #17b678; transition: all 0.2s ease-in; display: inline-block; padding: 10px 25px; color: #fff; text-decoration: none; position: relative; float: left;
}
.btn:hover { background-color: #089475;
}
.btn.loading { background-color: #089475; padding: 10px 70px 10px 25px;
}
.btn.loading::after { visibility: visible; opacity: 1; width: 20px; height: 20px; transition: all 0.2s ease-in; transition-delay: 0.3s;
}
.btn::after { visibility: hidden; opacity: 0; content: ""; position: absolute; top: calc(50% - 12px); right: 10px; border-left: 2px solid white; border-top: 2px solid transparent; border-right: 2px solid white; border-bottom: 2px solid transparent; border-radius: 50px; animation: rotate 1s infinite; animation-timing-function: linear;
}
.btn.e { background-color: red; animation: shake 0.82s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; transform: translate3d(0, 0, 0); animation-delay: 0.4s; backface-visibility: hidden;
}
.btn.s { background-color: #089475; padding: 10px 45px 10px 25px;
}
.btn.s::before { content: ""; position: absolute; width: 6px; height: 12px; animation: success 0.82s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; transform: rotate(45deg); animation-delay: 0.3s; backface-visibility: hidden; right: 15px; border-right: 3px solid #fff; border-bottom: 3px solid #fff;
}
@keyframes rotate { 100% { transform: rotate(360deg); }
}
@keyframes success { from { opacity: 0; } to { opacity: 1; }
}
@keyframes shake { 10%, 90% { transform: translate3d(-1px, 0, 0); } 20%, 80% { transform: translate3d(2px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-4px, 0, 0); } 40%, 60% { transform: translate3d(4px, 0, 0); }
}

CSS Processing Button - Script Codes JS Codes

// Test Functions -- these are just test functions that have been thrown togther
$(function(){	var $btn_text = $(".btn.p").text();	// Loading class, use on ajax etc	$(".btn.p").click(function(){	var $this = $(this);	$(".btn.p").text("Submitting...");	$this.addClass("loading");	})	// Add Success state, for ajax -- Needs to remove itself so form etc can be resubmitted	$(".success").click(function(){	var $this = $(this);	$(".btn.loading").text("Updated!");	$(".btn.loading").removeClass("loading").addClass("s");	setTimeout(reset, 2500);	})	// Add Error state, for ajax error fallover	$(".error").click(function(){	var $this = $(this);	$(".btn.loading").text("Error!");	$(".btn.loading").removeClass("loading").addClass("e");	setTimeout(reset, 2500);	})	// Reset Button	$(".reset").click(function(){	reset();	})	function reset(){	$(".loading").removeClass("loading");	$(".e").removeClass("e");	$(".s").removeClass("s");	$(".btn.p").text($btn_text);	}
});
CSS Processing Button - Script Codes
CSS Processing Button - Script Codes
Home Page Home
Developer Stephen Fray
Username stepfray
Uploaded January 20, 2023
Rating 3
Size 3,605 Kb
Views 4,048
Do you need developer help for CSS Processing Button?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Stephen Fray (stepfray) Script Codes
Create amazing SEO content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!