Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Pure CSS toggle switch</title>
<style>
body {
font-size: 2em;
}
input { position: absolute; opacity: 0 }
input + label::after {
content: ".";
border: 2px solid black;
border-radius: 600px;
margin-left: 12px;
width: 150px;
display: inline-block;
text-indent: -1000em;
}
input + label + input + label::after {
width: 0;
border-width: 0
}
input + label + input + label {
padding-right: 0;
padding-left: 150px;
margin-left: -150px;
background-image: -webkit-radial-gradient(circle, transparent 0%, transparent 50%, black 50%, black 54%, transparent 59%, transparent 100%);
background-position: 0px -1px;
background-size: 40px 105%;
background-repeat: no-repeat;
}
input:checked + label {
color: red
}
input + label + input:checked + label {
padding-left: 40px;
margin-left: -40px;
}
input + label + input + label {
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
transition: all 0.3s ease;
}
</style>
</head>
<body>
<input type="radio" id="i1" name="i" checked><label for="i1">Coffee</label><input type="radio" id="i2" name="i"><label for="i2">Tea</label>
<p>Discursive blog post at http://kryogenix.org/days/2013/06/01/pure-css-toggle-switch-with-two-labels</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.