Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <main>
	<header>Turn off computer</header>
	<div class="btn-block">
		<button id="stand-by" class="icon-btn icon-btn--yellow" type="button" aria-label="Stand By">
			<svg class="icon icon--stand-by" viewBox="0 0 24 24" width="24px" height="24px" aria-hidden="true">
				<g fill="none" stroke="#fff">
					<polyline class="icon__part icon__part--1" points="12,2 12,12" stroke-dasharray="10 10" stroke-width="3" data-anim-end />
					<circle class="icon__part icon__part--2" cx="12" cy="12" r="8" stroke-dasharray="50.265 50.265" stroke-dashoffset="-8.378" stroke-width="2" transform="rotate(-120,12,12)" />
				</g>
			</svg>
		</button>
		<span class="btn-block__u">S</span>tand By
	</div>
	<div class="btn-block">
		<button id="turn-off" class="icon-btn icon-btn--red" type="button" aria-label="Turn Off">
			<svg class="icon icon--turn-off" viewBox="0 0 24 24" width="24px" height="24px" aria-hidden="true">
				<g fill="none" stroke="#fff">
					<polyline class="icon__part icon__part--1" stroke-width="3" points="12,7 12,17" data-anim-end />
					<circle class="icon__part icon__part--2" cx="12" cy="12" r="9" stroke-dasharray="56.549 56.549" stroke-linecap="square" stroke-width="2" transform="rotate(-90,12,12)" />
				</g>
			</svg>
		</button>
		T<span class="btn-block__u">u</span>rn Off
	</div>
	<div class="btn-block">
		<button id="restart" class="icon-btn icon-btn--green" type="button" aria-label="Restart">
			<svg class="icon icon--restart" viewBox="0 0 24 24" width="24px" height="24px" aria-hidden="true">
				<g fill="none" stroke="#fff" stroke-dasharray="6 17" stroke-dashoffset="-5">
					<polyline class="icon__part icon__part--1" points="0,0 0,11" stroke-width="3" transform="translate(12,12) rotate(0)" data-anim-end />
					<polyline class="icon__part icon__part--1" points="0,0 0,11" stroke-width="2" transform="translate(12,12) rotate(45)" />
					<polyline class="icon__part icon__part--1" points="0,0 0,11" stroke-width="3" transform="translate(12,12) rotate(90)" />
					<polyline class="icon__part icon__part--1" points="0,0 0,11" stroke-width="2" transform="translate(12,12) rotate(135)" />
					<polyline class="icon__part icon__part--1" points="0,0 0,11" stroke-width="3" transform="translate(12,12) rotate(180)" />
					<polyline class="icon__part icon__part--1" points="0,0 0,11" stroke-width="2" transform="translate(12,12) rotate(225)" />
					<polyline class="icon__part icon__part--1" points="0,0 0,11" stroke-width="3" transform="translate(12,12) rotate(270)" />
					<polyline class="icon__part icon__part--1" points="0,0 0,11" stroke-width="2" transform="translate(12,12) rotate(315)" />
				</g>
			</svg>
		</button>
		<span class="btn-block__u">R</span>estart
	</div>
	<footer><footer>
		</main>
              
            
!

CSS

              
                * {
	border: 0;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
:root {
	--trans-dur: 0.3s;
	font-size: calc(16px + (24 - 16) * (100vw - 320px) / (2560 - 320));
}
body,
button {
	font: 1em/1.5 Verdana, sans-serif;
}
body {
	background-color: hsl(223,10%,10%);
	display: flex;
	flex-direction: column;
	height: 100vh;
	transition:
		background-color var(--trans-dur),
		color var(--trans-dur);
}
header,
footer {
	background-color: hsl(227,73%,35%);
	display: flex;
	justify-content: space-between;
	align-items: center;
	width: 100%;
	min-height: 4.4rem;
	position: absolute;
}
header {
	font-family: Arial, sans-serif;
	font-size: 1.75em;
	line-height: 1;
	margin-bottom: 0.2rem;
	padding: 0 1.25rem;
	top: 0;
}
footer {
	bottom: 0;
}
header:after {
	background-image: linear-gradient(90deg,hsl(220,50%,47%),hsl(215,77%,91%),hsl(220,50%,47%));
	content: "";
	display: block;
	position: absolute;
	top: 100%;
	left: 0;
	width: 100%;
	height: 0.2rem;
}
main {
	background-image: radial-gradient(circle at center,hsl(220,84%,78%),hsl(224,67%,61%) 12em);
	color: hsl(0,0%,100%);
	display: flex;
	justify-content: center;
	align-items: center;
	margin: auto;
	position: relative;
	max-width: 31.4em;
	width: 100%;
	min-height: 20em;
}
.btn-block {
	width: 9em;
	text-align: center;
}
.btn-block__u {
	text-decoration: underline;
}
.icon-btn {
	background-color: hsl(0,0%,50%);
	border-radius: 0.5em;
	box-shadow:
		0 0 0 2px hsl(0,0%,100%) inset,
		-0.25em -0.25em 0.25em hsla(0,0%,0%,0.5) inset;
	cursor: pointer;
	display: flex;
	margin: 0 auto 0.25em auto;
	outline: transparent;
	position: relative;
	width: 3.3em;
	height: 3.3em;
	-webkit-appearance: none;
	appearance: none;
	-webkit-tap-highlight-color: transparent;
}
.icon-btn:before {
	background-color: hsla(0,0%,100%,0);
	background-image:
		radial-gradient(100% 100% at 0 0,hsla(0,0%,100%,0.5),hsla(0,0%,100%,0) 40%),
		radial-gradient(100% 100% at 90% 90%,hsla(0,0%,100%,0.15),hsla(0,0%,100%,0) 50%);
	border-radius: 0.25em;
	box-shadow: 0.5em 0.5em 0.5em hsla(0,0%,100%,0.15) inset;
	content: "";
	display: block;
	position: absolute;
	inset: 4px;
	transition: background-color var(--trans-dur);
}
.icon-btn:focus-visible:before,
.icon-btn:hover:before {
	background-color: hsla(0,0%,100%,0.2);
}
.icon-btn:active:before {
	background-color: hsla(0,0%,0%,0.2);
}
.icon-btn--green {
	background-color: hsl(119,51%,39%);
}
.icon-btn--red {
	background-color: hsl(12,76%,53%);
}
.icon-btn--yellow {
	background-color: hsl(37,96%,57%);
}
.icon {
	margin: auto;
	pointer-events: none;
	width: 2.4em;
	height: 2.4em;
}
.icon__part {
	animation-duration: 1s;
}
.icon-btn--animated .icon--stand-by .icon__part--1 { animation-name: standBy1; }
.icon-btn--animated .icon--stand-by .icon__part--2 { animation-name: standBy2; }

.icon-btn--animated .icon--stand-by .icon__part,
.icon-btn--animated .icon--turn-off .icon__part {
	transform-origin: 12px 12px;
}
.icon-btn--animated .icon--turn-off .icon__part {
	animation-timing-function: cubic-bezier(0.645, 0.045, 0.355, 1);
}
.icon-btn--animated .icon--turn-off .icon__part--1 { animation-name: turnOff1; }
.icon-btn--animated .icon--turn-off .icon__part--2 { animation-name: turnOff2; }

.icon-btn--animated .icon--restart .icon__part--1 {
	animation-name: restart1;
	animation-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Animations */
@keyframes standBy1 {
	from {
		animation-timing-function: cubic-bezier(0.645, 0.045, 0.355, 1);
		stroke-dashoffset: 0;
		transform: translate(0,0);
	}
	33.33% {
		animation-timing-function: cubic-bezier(0.645, 0.045, 0.355, 1);
		stroke-dashoffset: -7;
		transform: translate(0,7px);
	}
	66.67% {
		animation-timing-function: cubic-bezier(0.645, 0.03, 0.355, 2);
		stroke-dashoffset: 3;
		transform: translate(0,-6px);
	}
	to {
		stroke-dashoffset: 0;
		transform: translate(0,0);
	}
}
@keyframes standBy2 {
	from {
		animation-timing-function: cubic-bezier(0.645, 0.045, 0.355, 1);
		stroke-dashoffset: -8.378;
		transform: rotate(-120deg);
	}
	33.33% {
		animation-timing-function: cubic-bezier(0.645, 0.045, 0.355, 1);
		stroke-dashoffset: 0;
		transform: rotate(-90deg);
	}
	66.67% {
		animation-timing-function: cubic-bezier(0.645, 0.03, 0.355, 2);
		stroke-dashoffset: -13.96;
		transform: rotate(-140deg);
	}
	to {
		stroke-dashoffset: -8.378;
		transform: rotate(-120deg);
	}
}
@keyframes turnOff1 {
	from {
		transform: rotate(0);
	}
	33.33% {
		transform: rotate(45deg);
	}
	66.67% {
		transform: rotate(-225deg);
	}
	to {
		transform: rotate(-180deg);
	}
}
@keyframes turnOff2 {
	from {
		stroke-dashoffset: 0;
		transform: rotate(-90deg);
	}
	33.33% {
		stroke-dashoffset: 7.069;
		transform: rotate(-45deg);
	}
	66.67% {
		stroke-dashoffset: 49.48;
		transform: rotate(-540deg);
	}
	to {
		stroke-dashoffset: 0;
		transform: rotate(-450deg);
	}
}
@keyframes restart1 {
	from { stroke-dashoffset: -5; }
	to { stroke-dashoffset: -28; }
}
              
            
!

JS

              
                window.addEventListener("DOMContentLoaded",() => {
	const standBy = new IconButton("#stand-by");
	const turnOff = new IconButton("#turn-off");
	const restart = new IconButton("#restart");
});

class IconButton {
	animClass = "icon-btn--animated";

	constructor(el) {
		this.el = document.querySelector(el);

		this.init();
	}
	init() {
		const events = ["focus", "mouseover", "touchstart"];
		events.forEach(ev => {
			this.el?.addEventListener(ev,this.iconAnimPlay.bind(this));
		});

		const animEndEl = this.el?.querySelector("[data-anim-end]");
		animEndEl?.addEventListener("animationend",this.iconAnimStop.bind(this));
	}
	iconAnimPlay() {
		this.el?.classList.add(this.animClass);
	}
	iconAnimStop() {
		this.el?.classList.remove(this.animClass);
	}
}
              
            
!
999px

Console