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

              
                - var cols = 3;
- var rows = 8;
main
	- for (var c = 0;c < cols;++c) {
		.column
			- for (var s = 0;s < rows;++s) {
				.soldier
					.torso
						.head
							.hat
							.visor
						.left-arm
							.musket
								.bayonet
								.butt
							.hand
						.right-arm
							.hand
						.wind-up-handle
						.left-leg
							.ankle
								.foot
						.right-leg
							.ankle
								.foot
			- }
	- }
              
            
!

CSS

              
                $dur: 2.5s;
$rows: 8;

*, *:before, *:after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
:root {
	font-size: 10px;
}
body {
	background-color: #111;
}
main {
	background-color: #b8803b;
	display: flex;
	justify-content: center;
	align-items: center;
	height: 100vh;
	margin: auto;
	overflow: hidden;
	position: relative;
	perspective: 720px;
	white-space: nowrap;
	max-width: 720px;
}
.column {
	position: absolute;
	transform: translateZ(0);
}
@for $c from 1 through $rows {
	.column:nth-child(#{$c + 1}) {
		transform: translateZ(-21em * $c);
		z-index: -$c;
	}
}
.soldier {
	animation: march $dur ease-out infinite;
	display: inline-block;
	position: relative;
	width: 15em;
	height: 21em;
	transform: translate(-50%);
	will-change: transform;
	z-index: 0;
}
.soldier div {
	position: absolute;
}
/* Uniform color */
.torso, .hat {
	background-color: #a02;
}
/* Skin */
.head, .hand {
	background-color: #fdb;
}
/* Head */
.head {
	background-image: linear-gradient(85deg,transparent 55%,#fff 55%,#fff 65%,transparent 65%);
	border-radius: 50%;
	top: -2.6em;
	left: 0;
	width: 3em;
	height: 3em;
}
.hat {
	background-image: radial-gradient(1.5em 0.25em at 100% 65%,#fff 1.4em, transparent 1.5em);
	border-radius: 50% / 0.25em;
	bottom: 2em;
	height: 4.5em;
	width: 3em;
	z-index: 1;
}
.visor {
	background-color: #000;
	border-radius: 50%;
	top: 0.6em;
	left: 1.5em;
	height: 0.5em;
	width: 2.5em;
}
/* Torso */
.torso {
	background-image:
		radial-gradient(2.5em 1em at 50% 0,transparent 60%,#fff 60%,#fff 99%,transparent 99%),
		radial-gradient(6em 4em at 50% 0,transparent 85%,#fff 85%,#fff 99%,transparent 99%);
	border-radius: 2em 2em 0.4em 0.4em;
	top: 6em;
	left: 6em;
	width: 3em;
	height: 7em;
	transform-origin: 50% 6em;
}
.wind-up-handle {
	animation: unwind $dur linear infinite;
	background:
		radial-gradient(0.5em 0.5em at 0.5em 0.5em, transparent 39%,#ccc 40%,#ccc 98%,transparent 99%),
		radial-gradient(0.5em 0.5em at 0.5em 1.5em, transparent 39%,#ccc 40%,#ccc 98%,transparent 99%),
		linear-gradient(transparent 40%,#ccc 40%,#ccc 60%,transparent 60%) 0.2em 0 no-repeat;
	top: 50%;
	right: 100%;
	width: 1.5em;
	height: 2em;
}
/* Pivot points and animations for arms and legs */
.left-arm, .right-arm, .left-leg, .right-leg, .ankle {
	transform-origin: 1em 1em;
}
.right-arm, .left-leg, .right-leg, {
	animation: pivot $dur/2 ease-out infinite;
}
.left-arm, .left-leg {
	animation-delay: -$dur/4;
}
/* Arms */
.left-arm, .right-arm {
	background-color: #c24;
}
.left-arm {
	animation: rock $dur/2 ease-out infinite;
	background-image: linear-gradient(transparent 68%,#fff 68%);
	top: 2.75em;
	left: 1em;
	width: 2em;
	height: 3em;
	transform: rotate(-60deg);
	transform-origin: 50% 0;
	z-index: -1;
}
.right-arm {
	background-image: linear-gradient(transparent 84%,#fff 84%);
	border-radius: 1em 1em 0 0;
	top: 0.5em;
	left: 0.5em;
	width: 2em;
	height: 6em;
	z-index: 1;
}
/* Musket parts */
.musket, .butt {
	background-color: #222;
}
.musket {
	border-radius: 0.3em 0.3em 0 0;
	width: 0.7em;
	height: 11em;
	left: 2.5em;
	bottom: 0.5em;
}
.bayonet {
	box-shadow: -0.2em -0.4em 0 #333 inset;
	bottom: 95%;
	width: 1em;
	height: 4em;
}
.butt {
	background-color: #222;
	border-radius: 0.3em;
	right: 0;
	top: 9em;
	width: 1.1em;
	height: 3.5em;
}
/* Hand positions */
.hand {
	top: 100%;
}
.left-arm .hand {
	border-radius: 0.5em 1em 1em 1em;
	left: 25%;
	width: 2.5em;
	height: 1.5em;
}
.right-arm .hand {
	border-radius: 0.5em 0.5em 50% 50%;
	top: 100%;
	height: 2em;
	width: 2em;
}
/* Legs */
.left-leg, .right-leg, .ankle, .foot {
	background-color: #111;
}
.left-leg, .right-leg, .ankle {
	width: 2em;
	height: 5.5em;
}
.left-leg, .right-leg {
	border-radius: 1em;
	top: 6em;
	left: 0.5em;
}
.ankle {
	border-radius: 1em 1em 0 0;
	top: 3.5em;
}
.foot {
	border-radius: 1em 2em 1em 0.5em /  1.5em 1.5em 0.5em 0.5em;
	top: 4.5em;
	left: -0.3em;
	width: 3.5em;
	height: 1em;
}

@keyframes march {
	from {transform: translateX(-50%)}
	25% {transform: translateX(-25%)}
	50% {transform: translateX(0)}
	75% {transform: translateX(25%)}
	to {transform: translateX(50%)}
}
@keyframes pivot {
	from, to {transform: rotate(22deg)}
	50% {transform: rotate(-22deg)}
}
@keyframes rock {
	from, to {transform: rotate(-60deg)}
	50% {transform: rotate(-62deg)}
}
@keyframes unwind {
	from {transform: rotateX(0)}
	to {transform: rotateX(1turn)}
}

/* Hide some offscreen soldiers based on viewport for performance reason */
@media screen and (max-width: 500px) {
	.soldier:first-child, .soldier:last-child {
		visibility: hidden;
	}
}
@media screen and (max-width: 320px) {
	.soldier:nth-child(-n + 2), .soldier:nth-child(n + 7) {
		visibility: hidden;
	}
}
              
            
!

JS

              
                
              
            
!
999px

Console