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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                
<html>
	<head>
		<meta charset="utf-8">
		<title>On off switch</title>

		<link rel="stylesheet" href="styles.css">

	</head>
	<body>

		<div class="wrapper">

			<label class="switch-label">
				<input type="checkbox" name="switch" value="" class="switch-input">
				<span class="inner">
					<span class="circle"></span>
					<span class="text">
						<span class="on">N</span>
						<span class="off">FF</span>
					</span>
				</span>
			</label>

		</div>

	</body>
</html>

              
            
!

CSS

              
                
html, body
	padding: 0
	margin: 0


body
	background: #f2f2f2
	font-family: arial, sans-serif

.wrapper
	display: flex
	align-items: center
	justify-content: center
	width: 100%
	height: 100vh

	&::before
		content: ''
		background: #68af3e
		position: absolute
		top: 0
		bottom: 0
		left: 0
		width: 50%

.switch-label
	position: relative
	width: 91px
	height: 34px
	border-radius: 20px
	overflow: hidden
	background: white
	cursor: pointer
	box-shadow: -3px 10px 39px -13px rgba(12, 51, 109, 0.65)

	.switch-input
		opacity: 0

	.inner
		height: 100%

		.circle
			position: absolute
			left: 10px
			top: 8px
			width: 14px
			height: 14px
			border-radius: 50%
			border: 2px solid #555
			transition: all .4s

		.text
			position: absolute
			top: 0
			left: -65px
			display: block
			width: 174px
			height: 100%
			font-size: 21px
			letter-spacing: 5px
			color: #555
			pointer-events: none
			transition: all .5s

			.off
				position: absolute
				right: 38px
				top: 5px
				transition: all 0s .15s

			.on
				position: absolute
				top: 4px
				left: 54px
				transform: rotate(180deg)
				opacity: 0
				transition: all 0s .15s

.switch-input:checked +
	.inner
		.circle
			background: #49c500
			border-color: #fff
			box-shadow: 0 0 0 65px rgba(73, 197, 0,1)

		.text
			transform: rotate(180deg)

			.on
				opacity: 1
				color: #fff

			.off
				opacity: 0

              
            
!

JS

              
                
              
            
!
999px

Console