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>
	<input id="toggle" type="checkbox" name="toggle" role="switch" value="on">
	<label for="toggle" class="surface">
		<span class="cube">
			<span class="cube__front"></span>
			<span class="cube__left"></span>
			<span class="cube__top"></span>
			<span class="cube__reflection"></span>
		</span>
		<span class="cube">
			<span class="cube__front"></span>
			<span class="cube__left"></span>
			<span class="cube__top"></span>
		</span>
		<span class="label-text">Power</span>
	</label>
</form>
              
            
!

CSS

              
                *
	border: 0
	box-sizing: border-box
	margin: 0
	padding: 0

\:root
	--dur: 0.3s
	--timing: cubic-bezier(0.3,1.7,0.6,0.6)
	--offColor: #2d7a06
	--onColor: #6af425
	font-size: calc(40px + (80 - 40)*(100vw - 320px)/(2560 - 320))

body
	background-color: #e3e4e8
	color: #17181c
	font: 1em/1.5 "Helvetica Neue", Helvetica, sans-serif
	overflow-x: hidden

form
	display: flex
	height: 100vh

.surface, .cube__front, .cube__left, .cube__top
	background-color: var(--offColor)

.surface, .surface span
	display: block

.surface, .cube
	transform-style: preserve-3d

.surface
	box-shadow: 0 0 1em transparent
	transition: all var(--dur) ease-out
	cursor: pointer
	margin: auto
	position: relative
	transform: rotateX(45deg) rotateZ(-45deg) translateY(-0.5em)
	width: 4em
	height: 2em
	-webkit-tap-highlight-color: transparent

.cube, .cube span, .label-text
	position: absolute
	left: 0

.cube
	&, span
		top: 0
	&__front, &__left, &__top, &__reflection
		height: 2em
		width: 2em
	&__front, &__left, &__top
		transition: background-color var(--dur) ease-out, transform var(--dur) var(--timing)
	&__front
		background-image: linear-gradient(rgba(0,0,0,0.1),rgba(0,0,0,0.1))
		transform: rotateX(-90deg)
			origin: 50% 100%
	&__left
		background-image: linear-gradient(rgba(0,0,0,0.2),rgba(0,0,0,0.2))
		transform: rotateY(-90deg)
			origin: 0 50%
	&__top
		transform: translateZ(2em)
	&__reflection
		background-color: #000
		$clipPathA: polygon(0 0,100% 0,100% 100%,0% 100%,0 100%)
		clip-path: $clipPathA
		-webkit-clip-path: $clipPathA
		opacity: 0.04
		transform: rotate(45deg) scale(0.707)
			origin: 0 0
		transition: clip-path var(--dur) var(--timing), -webkit-clip-path var(--dur) var(--timing)
	&:nth-child(2)
		transform: translate(2em,0)
		.cube
			&__front
				transform: rotateX(-90deg) scaleY(0.25)
			&__left
				transform: rotateY(-90deg) scaleX(0.25)
			&__top
				transform: translateZ(0.5em)

input[type=checkbox]
	position: fixed
	top: -1.5em
	left: -1.5em
	&:checked + .surface
		box-shadow: 0 0 1em var(--onColor)
		&, .cube__front, .cube__left, .cube__top
			background-color: var(--onColor)
		.cube
			&__front
				transform: rotateX(-90deg) scaleY(0.25)
			&__left
				transform: rotateY(-90deg) scaleX(0.25)
			&__top
				transform: translateZ(0.5em)
			&__reflection
				$clipPathB: polygon(0 0,100% 0,100% 100%,67% 100%,0 33%)
				clip-path: $clipPathB
				-webkit-clip-path: $clipPathB
			&:nth-child(2)
				.cube
					&__front
						transform: rotateX(-90deg)
					&__left
						transform: rotateY(-90deg)
					&__top
						transform: translateZ(2em)

.label-text
	top: calc(100% + 0.5em)
	width: 100%
	text-align: center
	text-transform: uppercase

@media (prefers-color-scheme: dark)
	body
		background-color: #2e3138
		color: #e3e4e8
	.cube__reflection
		opacity: 0.08
              
            
!

JS

              
                
              
            
!
999px

Console