Simple Activate / De-Activate switch using Simple Css | Sanwebcorner

Simple Activate / De-Activate switch using Simple Css

In this section i want to explain about how to create simple activate deactivate switch using the simple css3. Here we design the buttons with the help of css3. The button design css code is below

.switch {
position: relative;
display: inline-block;
width: 75px;
height: 34px;
}

This code is used to design the button you can change here height and width of the switch / button. Inside the button we have one slider circle the following code is used to create that white circle inside the button.

.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}


Normal position of the switch is in red. When you clicked it turns in to green that means active status when you clicked again it turns in red that means de-active status. that will be done below css code.

.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: red;
-webkit-transition: .4s;
transition: .4s;
}

input:checked + .slider {
background-color: green;
}

This is very useful you can use this activate and deactivate button in several web applications. It is very simple and nice and also you can create this using simple css3 code. Here is the full code available. you can download the code and use it your projects. And also provided demo page, please checkout the demo page then you can know how the buttons are working...

Code for Activate De-Activate Switch :

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> Simple Activate / De-Activate switch using Simple Css </title>
<style>
.switch {
position: relative;
display: inline-block;
width: 75px;
height: 34px;
}

.switch input {display:none;}

.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: red;
-webkit-transition: .4s;
transition: .4s;
}

.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}

input:checked + .slider {
background-color: green;
}

input:focus + .slider {
box-shadow: 0 0 1px green;
}

input:checked + .slider:before {
-webkit-transform: translateX(40px);
-ms-transform: translateX(40px);
transform: translateX(40px);
}

/* Rounded sliders */
.slider.round {
border-radius: 34px;
}

.slider.round:before {
border-radius: 50%;
}
</style>
</head>
<body>
<h2>Toggle Switch using simple css</h2>
<label class="switch">
<input type="checkbox" checked>
<span class="slider round"></span>
</label>
<label class="switch">
<input type="checkbox" >
<span class="slider round"></span>
</label>
</body>
</html> 

Post a Comment

Labels

360 degree view product image 3d rotate 3d text 3step-form Accordion menu ajax All Browsers Animated Background Gradient animation audio controller auto complete Best accordion menu bootstrap border bounce effect on hover Breadcrumb calculate age by dob calendar Captcha change image on mouse move color chooser countdown Counter on scroll create random number Css css animation css buttons css hover css3 customized upload Button Date picker delete data from table Different scroll speed email otp verification email verifier Embed eventlist Expanding Menu feedbck form flash news section close button full screen menu Google custom search Google Maps Google reCAPTCHA Google site search gradient hide menu Horizontal News ticker Hover Htm Html html dropdown html form html5 html5 form validation Iframe image hover increment decrement textbox value based on select box Javascript Jquery js Layered image effect on mouse hover lock & unlock page scroll marquee marquee with close button mobile number validation mobile otp login Multi-level-drop-down-menu multi-level-form Multi-Step-form mysql News ticker on hover change text to image our team page password generator password strength checker Photoshop PHP populate html selectbox Popup image on click the link pure css Question type form random number generate Random password Redirect page Based on the select box while submit the form responsive responsive menu responsive popup box Responsive Vertical Time line design rotate image selectbox based on select box simple coming soon page simple countdown based on end date simple typing effect slider sliding tab sms otp login statistic counter on scroll switch tag shape team member Time picker toggle toggle view transparent button underline animation up down slide validation vertical fixed sidebar Webtips Youtube