Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <form>
	<label>
		<input type="radio" name="dummy" value="top" checked> <span>Top</span>
	</label>
	<label>
		<input class="pristine" type="radio" name="dummy" value="middle"> <span>Middle</span>
	</label>
	<label>
		<input class="pristine" type="radio" name="dummy" value="bottom"> <span>Bottom</span>
	</label>
	<br>
	<button type="reset">Reset</button>
</form>
              
            
!

CSS

              
                * {
	border: 0;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
:root {
	--fg: #17181c;
	--trans: 0.15s;
	font-size: calc(30px + (40 - 30) * (100vw - 320px) / (1280 - 320));
}
body, button, input {
	font: 1em/1.5 "Hind", sans-serif;
}
body {
	background-color: #79934f;
	color: var(--fg);
	display: flex;
	height: 100vh;
}
button, input, label {
	cursor: pointer;
	-webkit-tap-highlight-color: #0000;
}
button, input {
	-webkit-appearance: none;
	appearance: none;
}
button, input[type=radio]:focus {
	outline: 0;
}
button {
	background-color: #255ff4;
	border-radius: 0.2em;
	color: #fff;
	display: block;
	margin: auto;
	padding: 0.5em 1em;
	transition: background-color var(--trans) linear;
}
button:focus, button:hover {
	background-color: #0b46da;
}
button:active {
	transform: translateY(0.1em);
}
form {
	margin: auto;
	padding: 1.5em 0;
}
input[type=radio], input[type=radio]:before, input[type=radio]:after, .dirt, .dust, .dust-fog {
	border-radius: 50%;
}
input[type=radio]:before, input[type=radio]:after, .dirt, .dust, .dust-fog {
	position: absolute;
}
input[type=radio], label {
	position: relative;
}
input[type=radio] {
	--dur: 0.6s;
	animation: createHole var(--dur) steps(1);
	background-image:
		radial-gradient(1em 1em at 0.5em 0.5em,#b38d56 49%,#b38d5600 50%),
		radial-gradient(1em 1em at 1.5em 0.5em,#2f2215 9%,#523c25 10% 19%,#7c6139 20% 29%,#a8824c 30% 39%,#b38d56 40% 49%,#b38d5600 50%);
	background-position: -1em 0;
	background-repeat: no-repeat;
	background-size: 2em 1em;
	font-size: 2em;
	margin-right: 0.5rem;
	width: 1em;
	height: 1em;
}
input[type=radio]:before, input[type=radio]:after {
	content: "";
	display: block;
	transform: scale(0);
}
input[type=radio]:before {
	animation: burrow var(--dur) linear;
	background-image:
		radial-gradient(100% 100% at center,#45495400 19%,#454954 20% 24%,#818897 25% 39%,#81889700 40%),
		repeating-conic-gradient(from 0 at center,#737a8c 0deg 10deg,#737a8c00 11deg 29deg,#737a8c 30deg 40deg);
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}
input[type=radio]:after {
	animation: hubIn var(--dur) linear;
	background-color: #255ff4;
	box-shadow: 0 -0.1em 0 #0b46da inset;
	top: 30%;
	left: 30%;
	width: 40%;
	height: 40%;
}
input[type=radio]:checked:before, input[type=radio]:checked:after {
	transform: scale(1);
}
input[type=radio]:checked:before {
	animation: surface var(--dur) linear;
}
input[type=radio]:checked:after {
	animation: hubOut var(--dur) linear;
}
input[type=radio].pristine, input[type=radio].pristine:before, input[type=radio].pristine:after {
	animation: none;
}
input[type=radio].pristine {
	background-position: 0 0;
}
input[type=radio] + span {
	transition: color var(--trans) linear;
}
input[type=radio]:focus + span {
	color: #dbc9a4;
}
label {
	background-color: #a8824c;
	border-radius: 0.25em;
	box-shadow: 0 0.05em 0 0.05em #5e723d inset;
	display: flex;
	align-items: center;
	margin-bottom: 0.5em;
	padding: 0.25em 0.5em 0.25em 0.25em;
}
.dirt, .dust, .dust-fog {
	display: block;
	top: 50%;
	left: 1.25em;
	pointer-events: none;
}
.dirt {
	background-color: #7c6139;
	width: 0.4em;
	height: 0.4em;
	z-index: 1;
	transform: translate(-0.2em,-0.2em) scale(0);
}
.dust {
	background-color: #ccb380;
	width: 0.8em;
	height: 0.8em;
	z-index: 2;
	transform: translate(-0.4em,-0.4em) scale(0);
}
.dust-fog {
	background-color: #ccb38020;
	width: 1em;
	height: 1em;
	z-index: 3;
	transform: translate(-0.5em,-0.5em) scale(0);
}
/* Animations */
@keyframes burrow {
	from {
		transform: rotate(0turn) scale(1);
	}
	50% {
		transform: rotate(0.5turn) scale(1.2);
	}
	to {
		transform: rotate(1turn) scale(0);
	}
}
@keyframes createHole {
	from {
		background-position: 0 0;
	}
	to {
		background-position: -1em 0;
	}
}
@keyframes hubIn {
	from {
		transform: scale(1);
	}
	50% {
		transform: scale(1.2);
	}
	to {
		transform: scale(0);
	}
}
@keyframes hubOut {
	from {
		transform: scale(0);
	}
	50% {
		transform: scale(1.2);
	}
	to {
		transform: scale(1);
	}
}
@keyframes surface {
	from {
		transform: rotate(0turn) scale(0);
	}
	50% {
		transform: rotate(0.5turn) scale(1.2);
	}
	to {
		transform: rotate(1turn) scale(1);
	}
}
              
            
!

JS

              
                document.addEventListener("DOMContentLoaded",init.bind(document,"dummy"));

function init(inputName) {
	let form = this.forms[0];
	if (form) {
		let prevTar = null,
			inputs = Array.from(this.getElementsByName(inputName));
		// blade popping in and out
		form.addEventListener("change",e => {
			let tar = e.target;
			if (tar) {
				// previous value
				if (prevTar)
					splatterParticles(prevTar,"dirt",25);
				prevTar = tar;
				// current value, use dust particles the first time the radio is checked
				if (tar.classList.contains("pristine")) {
					tar.removeAttribute("class");
					splatterParticles(tar,"dust",60);
					splatterParticles(tar,"dust-fog",15);
				}
				splatterParticles(tar,"dirt",20);
			}
		});
		// set everything back to pristine state
		form.addEventListener("reset",E => {
			prevTar = null;
			inputs.forEach((e,i) => {
				e.className = "pristine";
				e.checked = false;
			});
			E.preventDefault();
		});
		// particles for value on load
		splatterParticles(inputs[0],"dirt",20);
	}
}
function propertyUnitsStripped(el,property,unit) {
	let cs = window.getComputedStyle(el),
		valueRaw = cs.getPropertyValue(property),
		value = +valueRaw.substr(0,valueRaw.indexOf(unit));
	return value;
}
function splatterParticles(target,particleType = "dirt",particleCount = 1) {
	let parent = target.parentElement;
	if (parent) {
		let baseDur = propertyUnitsStripped(target,"--dur","s") * 1000,
			// particle objects
			dirt = {
				dist: {
					start: 0.5,
					min: 1.5,
					max: 2
				},
				diam: {
					min: 0.2,
					max: 0.4
				},
				delay: {
					min: baseDur * 0.25,
					max: baseDur * 0.5
				},
				dur: baseDur,
				end_opacity: 1,
				end_scale: 0
			},
			dust = {
				dist: {
					start: 0,
					min: 2.5,
					max: 3
				},
				diam: {
					min: 0.8,
					max: 1
				},
				delay: {
					min: 0,
					max: 0
				},
				dur: baseDur,
				end_opacity: 0,
				end_scale: 0.5
			},
			dustFog = {
				dist: {
					start: 0,
					min: 1,
					max: 1.5
				},
				diam: {
					min: 1,
					max: 1.5
				},
				delay: {
					min: baseDur * 0.1,
					max: baseDur * 0.2
				},
				dur: baseDur * 4,
				end_opacity: 0,
				end_scale: 1
			},
			// parameters common for all particles
			pObj = particleType == "dust" ? dust : (particleType == "dust-fog" ? dustFog : dirt),
			nearestEm = 0.01,
			distStart = pObj.dist.start,
			dur = pObj.dur,
			endOpacity = pObj.end_opacity,
			endScale = pObj.end_scale;
		// spawn the particles
		for (let i = 0; i < particleCount; ++i) {
			let p = document.createElement("span");
			p.className = particleType;
			parent.appendChild(p);
			// randomized parameters for each particle
			let rot = Math.floor(Math.random() * 360),
				diam = pObj.diam.min + Math.round(Math.random() * (pObj.diam.max - pObj.diam.min) / nearestEm) * nearestEm,
				rad = diam / 2,
				dist = pObj.dist.min + Math.round(Math.random() * (pObj.dist.max - pObj.dist.min) / nearestEm) * nearestEm,
				delay = pObj.delay.min + Math.round(Math.random() * (pObj.delay.max - pObj.delay.min));

			p.style.width = `${diam}em`;
			p.style.height = `${diam}em`;
			// animation
			let transStart = `translate(${-rad}em,${-rad}em) rotate(${rot}deg)`,
				seq = p.animate(
				[
					{
						transform: `${transStart} translateX(${distStart}em) scale(0)`,
						opacity: 1
					},
					{
						transform: `${transStart} translateX(${distStart + (dist - distStart)/2}em) scale(1)`,
						opacity: 1
					},
					{
						transform: `${transStart} translateX(${dist}em) scale(${endScale})`,
						opacity: endOpacity
					}
				],
				{
					duration: dur,
					easing: "cubic-bezier(0.1,0.6,0.4,0.9)",
					delay: delay
				}
			);
			seq.onfinish = p.remove.bind(p);
		}
	}
}
              
            
!
999px

Console