Created
November 28, 2012 20:06
-
-
Save arjabbar/4163845 to your computer and use it in GitHub Desktop.
A CodePen by Abdur Jabbar. On/Off Switch - A switch inspired by a dribbble by Elias Chikunov.
http://dribbble.com/shots/829459-Toggle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div><input type="checkbox" /><i></i></div> | |
Inspired by <a href="http://dribbble.com/shots/829459-Toggle">Elias Chikunov</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//A little jquery because I put the <i> in the way of the checkbox. | |
$('i').click(function(){ | |
if ($('input').attr('checked')) | |
{ | |
$('input').removeAttr('checked'); | |
} else { | |
$('input').attr('checked', 'checked'); | |
} | |
}); | |
/* | |
A switch inspired by a dribbble by Elias Chikunov. | |
http://dribbble.com/shots/829459-Toggle | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url(http://fonts.googleapis.com/css?family=Archivo+Narrow); | |
html { | |
font-family: 'Archivo Narrow', sans-serif; | |
font-smooth: anti-alias; | |
font-size: 2em; | |
height: 100%; | |
background: url(http://subtlepatterns.subtlepatterns.netdna-cdn.com/patterns/tex2res3.png); | |
text-align: center; | |
} | |
div { | |
cursor: pointer; | |
} | |
input { | |
cursor: pointer; | |
display: block; | |
margin-left: auto; | |
margin-right: auto; | |
margin-top: 50px; | |
appearance: button; | |
background: white; | |
border-radius: 10px; | |
box-shadow: inset 0 20px 70px -20px lightgrey, inset 0 3px 10px lightgrey, inset 0 1px 5px 0 grey, 0 2px 10px -5px white; | |
width: 190px; | |
height: 60px; | |
z-index: 1; | |
} | |
input:before { | |
position: relative; | |
content: "ON"; | |
font-size: 2em; | |
font-weight: 800; | |
top: 15px; | |
left: 30px; | |
background: linear-gradient(top, rgb(100,100,251), aqua); | |
-webkit-background-clip: text; | |
color: transparent; | |
} | |
input:after { | |
position: relative; | |
content: "OFF"; | |
font-size: 2em; | |
font-weight: 800; | |
top: 15px; | |
left: 75px; | |
background: linear-gradient(bottom, rgb(225,225,225), rgb(180,180,180)); | |
-webkit-background-clip: text; | |
color: transparent; | |
} | |
i { | |
position: relative; | |
display: block; | |
background-color: white; | |
background-image: linear-gradient(left, transparent 40%, rgba(100,100,100,0.3) 40%,transparent 41%, transparent 50%, rgba(100,100,100,0.3) 50%, transparent 51.5%, transparent 60%, rgba(100,100,100,0.2) 60%,transparent 61%, transparent); | |
box-shadow: inset 0 -10px 70px -20px lightgrey, 0 0 1px lightgrey, 0 5px 10px -5px grey, inset 0 0 1px 10px white; | |
margin-left: auto; | |
margin-right: auto; | |
bottom: 60px; | |
width: 95px; | |
height: 55px; | |
left: -45px; | |
border-radius: 10px; | |
transition: left 500ms; | |
z-index: 0; | |
} | |
input:checked ~ i{ | |
left: 45px; | |
} | |
a { | |
text-decoration: none; | |
color: white; | |
text-shadow: 0 0 7px blue, 0 0 7px blue, 0 0 7px blue; | |
transition: text-shadow 250ms; | |
} | |
a:hover { | |
text-shadow: 0 0 10px red, 0 0 10px blue, 0 0 10px yellow; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment