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

              
                <div id="container">
  <p class="title">CLEAN SWITCH WITHOUT BACKGROUND IMAGE</p>
		
    <div style="margin : 0 auto; width : 300px">
    <div class="clean_switch"></div>
		<div class="clean_switch on"></div>
      
    <div class="clean_switch3"></div>
    <div class="clean_switch3 on"></div>
  </div>
</div>
              
            
!

CSS

              
                *{
	padding : 0;
	margin : 0;
}

html{
	background : #e2e2e2;
	padding : 20px;
}

#container{
	width : 450px;
	margin : 20px auto;
}

p.title{
  color : #fff;
  text-shadow : -1px -1px 0 #9f9f9f;
  line-height : 50px;
  font-size : 30px;
  text-align : center;
}

.clean_switch{
	position : relative;
	width : 60px;
	height : 20px;
	display : inline-block;
	margin : 35px;
	
	border-radius: 10px;
	box-shadow : 0 2px 6px rgba(0,0,0,0.75) inset;

	background : #363636;
	background-image : -moz-linear-gradient(top , rgba(0,0,0,0.1) 0% , rgba(255,255,255,0.1) 50% , rgba(0,0,0,0.1) 100%);
  background-image : -webkit-linear-gradient(top , rgba(0,0,0,0.1) 0% , rgba(255,255,255,0.1) 50% , rgba(0,0,0,0.1) 100%);
}

.clean_switch:before{
	position : absolute;
	content : "";
	left : -15px; right : -15px;
	top : -10px; bottom : -10px;
	z-index : -2;
	background : #d2d1d2;

	border-radius: 20px;
	box-shadow : 0 1px 1px rgba(0,0,0,0.75) inset,
	0 -1px 1px rgba(255,255,255,0.75) inset;
}

.clean_switch:after{
	position : absolute;
	content : "";
	left : -5px; right : 45px;
	top : 0px; bottom : 0px;
	z-index : 1;
	opacity : 1;
	background : #b7b7b7;
	background-image : -moz-linear-gradient(top,rgba(255,255,255,0.4),rgba(0,0,0,0.4));
  background-image : -webkit-linear-gradient(top,rgba(255,255,255,0.4),rgba(0,0,0,0.4));
  
	border-radius: 10px;
	box-shadow : 0 1px 1px rgba(255,255,255,.75) inset,
	0 5px 4px rgba(0,0,0,0.8);
}
.clean_switch.on:after{
	-moz-animation : switchOn 1s 1 ease-in-out;
  -webkit-animation : switchOn 1s 1 ease-in-out;
	left : 45px;
	right : -5px;
}

.clean_switch.off:after{
	-moz-animation : switchOff 1s 1 ease-in-out;
  -webkit-animation : switchOff 1s 1 ease-in-out;
	left : -5px;
	right : 45px;
}

.clean_switch.off{
	-moz-animation : changeSwitchColorOff 1s 1 ease-in-out;
  -webkit-animation : changeSwitchColorOff 1s 1 ease-in-out;
	background : #363636;
  background-image : -moz-linear-gradient(top,rgba(255,255,255,0.4),rgba(0,0,0,0.4));
  background-image : -webkit-linear-gradient(top,rgba(255,255,255,0.4),rgba(0,0,0,0.4));
}

.clean_switch.on{
	-moz-animation : changeSwitchColorOn 1s 1 ease-in-out;
  -webkit-animation : changeSwitchColorOn 1s 1 ease-in-out;
	background : #39b54a;
  background-image : -moz-linear-gradient(top,rgba(255,255,255,0.4),rgba(0,0,0,0.4));
  background-image : -webkit-linear-gradient(top,rgba(255,255,255,0.4),rgba(0,0,0,0.4));
}

@-moz-keyframes changeSwitchColorOn{
	0%{
		background : #363636;
	}
	99%{
		background : #39b54a;
	}
	100%{
		background : #39b54a;
	}
}

@-moz-keyframes changeSwitchColorOff{
	0%{
		background : #39b54a;
	}
	99%{
		background : #363636;
	}
	100%{
		background : #363636;
	}
}

@-webkit-keyframes changeSwitchColorOn{
	0%{
		background : #363636;
	}
	99%{
		background : #39b54a;
	}
	100%{
		background : #39b54a;
	}
}

@-webkit-keyframes changeSwitchColorOff{
	0%{
		background : #39b54a;
	}
	99%{
		background : #363636;
	}
	100%{
		background : #363636;
	}
}

@-moz-keyframes switchOff{
	from{
		z-index :1;
		left : 45px;
		right : -5px;
	}
	to {
		z-index :1;
		right : 45px;
		left : -5px;
	}
}

@-moz-keyframes switchOn{
	from {
		z-index :1;
		right : 45px;
		left : -5px;
	}
	to{
		z-index :1;
		left : 45px;
		right : -5px;
	}
}

@-webkit-keyframes switchOff{
	from{
		z-index :1;
		left : 45px;
		right : -5px;
	}
	to {
		z-index :1;
		right : 45px;
		left : -5px;
	}
}

@-webkit-keyframes switchOn{
	from {
		z-index :1;
		right : 45px;
		left : -5px;
	}
	to{
		z-index :1;
		left : 45px;
		right : -5px;
	}
}

.clean_switch3{
	position : relative;
	display : inline-block;
	width : 120px;
	height : 40px;
	color : #f0f0f0;
	font-size: 21px;
	font-family: arial;
	border-radius: 5px;
	box-shadow : 0 2px 0px rgba(87,87,87,0.6) inset,
				0 2px 0px rgba(255,255,255,0.6);

	background : #b7b7b7;
	margin : 10px;
}
.clean_switch3:before{
	position : absolute;
	z-index : 1;
	content : "|||";
	color : #b7b7b7;
	text-indent: 15px;

	padding : 0px 5px 10px 5px;
	border-radius: 5px;
	background : #dcdcdc;
	box-shadow: 0 2px 1px rgba(255,255,255,0.5) inset,
				0 2px 0 rgba(87,87,87,0.5);
	left : 5px; right : 60px;
	top : 5px; bottom : 5px;
}
.clean_switch3.on{
	-moz-animation : changeSwitch2ColorOn 1s 1 ease-in-out;
  -webkit-animation : changeSwitch2ColorOn 1s 1 ease-in-out;
	background : #139748;

}
.clean_switch3.off{
	-moz-animation : changeSwitch2ColorOff 1s 1 ease-in-out;
  -webkit-animation : changeSwitch2ColorOff 1s 1 ease-in-out;
	background : #b7b7b7;
}
.clean_switch3.on:before{
	-moz-animation : switch2on 1s 1 ease-in-out;
  -webkit-animation : switch2on 1s 1 ease-in-out;
	color : #39b54a;
	left : 60px; right : 5px;
}

.clean_switch3.off:before{
	-moz-animation : switch2off 1s 1 ease-in-out;
  -webkit-animation : switch2off 1s 1 ease-in-out;
	left : 5px; right : 60px;
}
@-moz-keyframes switch2on{
	from{
		color : #b7b7b7;
		left : 5px; right : 60px;
	}
	to{
		color : #39b54a;
		left : 60px; right : 5px;
	}
}
@-webkit-keyframes switch2on{
	from{
		color : #b7b7b7;
		left : 5px; right : 60px;
	}
	to{
		color : #39b54a;
		left : 60px; right : 5px;
	}
}
@-moz-keyframes switch2off{
	from{
		color : #39b54a;
		left : 60px; right : 5px;	
	}
	to{
		color : #b7b7b7;
		left : 5px; right : 60px;
	}
}
@-webkit-keyframes switch2off{
	from{
		color : #39b54a;
		left : 60px; right : 5px;	
	}
	to{
		color : #b7b7b7;
		left : 5px; right : 60px;
	}
}
@-moz-keyframes changeSwitch2ColorOn{
	0%{
		background : #b7b7b7;
	}
	99%{
		background : #139748;
	}
	100%{
		background : #139748;
	}
}
@-webkit-keyframes changeSwitch2ColorOn{
	0%{
		background : #b7b7b7;
	}
	99%{
		background : #139748;
	}
	100%{
		background : #139748;
	}
}
@-webkit-keyframes changeSwitch2ColorOff{
	0%{
		background : #139748;
	}
	99%{
		background : #b7b7b7;
	}
	100%{
		background : #b7b7b7;
	}
}
@-webkit-keyframes changeSwitch2ColorOff{
	0%{
		background : #139748;
	}
	99%{
		background : #b7b7b7;
	}
	100%{
		background : #b7b7b7;
	}
}
              
            
!

JS

              
                $(function(){
		$('.clean_switch').click(function(){
			if($(this).hasClass('on')){
				$(this).removeClass('on');
				$(this).addClass('off');	
			}else if($(this).hasClass('off')){
				$(this).removeClass('off');
				$(this).addClass('on');
			}else if(!$(this).hasClass('on') && !$(this).hasClass('off')){
				$(this).addClass('on');
			}
		});
    $('.clean_switch3').click(function(){
			if($(this).hasClass('on')){
				$(this).removeClass('on');
				$(this).addClass('off');	
			}else if($(this).hasClass('off')){
				$(this).removeClass('off');
				$(this).addClass('on');
			}else if(!$(this).hasClass('on') && !$(this).hasClass('off')){
				$(this).addClass('on');
			}
		});
	});
              
            
!
999px

Console