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

              
                <section id="Wrapper" class="dark">
  <h1>switch on/off</h1>
  <div class="switch switchLightOff">
    <div class="hole holeLightOff">
      <div class="handle handleLightOff">
        <p>I<br /><span class="sk">O</span></p>
        <div class="handleTop handleTopLightOff"></div>
        <div class="handleBottom handleBottomLightOff"></div>
      </div>
    </div>
  </div>
  <p class="credits">Inspired by <a href="http://dribbble.com/shots/419656-Lighted-Rocker-Switch-V2?list=searches&tag=light_switch">Keith Sereby’s dribbble post</a></p>
</section>
<!-- insired by Keith Sereby’s dribbble post
http://dribbble.com/shots/419656-Lighted-Rocker-Switch-V2?list=searches&tag=light_switch 
-->
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Comfortaa);
@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,400);
* {
  margin:0px;
  padding:0px;
  -webkit-box-sizing:border-box;
  -moz-box-sizing:   border-box;
  box-sizing:        border-box;
}
/* positioning & layout */
#Wrapper {
  width: 100%;
  min-height: 100%;
  height: auto !important;
  height: 100%;
  overflow: hidden !important;
}
h1 {
  padding:2rem 0;
  font-family: 'Source Sans Pro', sans-serif;
  font-size:2rem;
  font-weight:200;
  text-transform:uppercase;
  text-align:center;
  color:rgba(255,255,255,0.3);
}
.credits {
  padding:2rem 0;
  font-family: 'Source Sans Pro', sans-serif;
  font-size:1.2rem;
  font-weight:400;
  text-align:center;
  color:rgba(0,0,0,0.55);
}
.credits a {
  position:relative;
  text-decoration:none;
  color:rgba(0,0,0,0.55);
}
.credits a:after {
  content:'';
  position:absolute;
  left:0px;
  bottom:-2px;
  width:0%;
  height:1px;
  background:rgba(0,0,0,0.55);
  transition:width 0.15s 0.15s;
}
.credits a:hover::after {
  width:100%;
  transition:width 0.15s;
} 
.switch {
  margin:2rem auto;
  width:100px;
  height:200px;
  border-radius:12px;
  cursor:pointer;
}
.hole {
  position:relative;
  width:80px;
  height:180px;
  margin:8px 10px;
  border-radius:8px;
  background:#000;
  box-shadow:1px 0px 3px rgba(0,0,0,0.3),
             -1px 0px 3px rgba(0,0,0,0.3),
             0px -1px 3px rgba(0,0,0,0.3);
}
.handle, .handleTop, .handleBottom {
  border-radius:2px;
}
.handle {
  position:absolute;  
  left:2px;
  right:2px;
  width:76px;
  height:120px;
  font-family: 'Comfortaa', cursive;
  font-size:2.1rem;
  line-height:3.8rem;
  text-transform:uppercase;
  text-align:center;
  -webkit-transform-style:preserve-3d;
  -moz-transform-style:   preserve-3d;
  -ms-transform-style:    preserve-3d;
  -o-transform-style:     preserve-3d;
  transform-style:        preserve-3d;
  -webkit-perspective:1000px;
  -moz-perspective:   1000px;
  -ms-perspective:    1000px;
  -o-perspective:     1000px;
  perspective:        1000px;
}
.sk {
  display:block;
}
.on {
  -webkit-transform:rotateX(35deg);
  -moz-transform:   rotateX(35deg);
  -ms-transform:    rotateX(35deg);
  transform:        rotateX(35deg);
}
.handleLightOff {
  top:40px;
  color:rgba(255,255,255,0.07);
  text-shadow:0px -1px 2px rgba(0,0,0,0.5),
              0px 1px 0px rgba(82,8,0,0.4);
}
.handleLightOn {
  top:17px;
  color:rgba(255,255,255,0.7);
  text-shadow:0px -1px 2px rgba(0,0,0,0.5),
              0px 1px 0px rgba(82,8,0,0.4);
}
.handleTop, .handleBottom {
  position:absolute;
  width:76px;
  right:0px;
}
.handleTopLightOff {
  top:-30px;
  left:0px;
  height:30px;
}
.handleTopLightOn {
  left:-2px;
  top:-12px;
  height:10px;
}
.handleBottomLightOff {
  bottom:-10px;
  left:0px;
  height:10px;
}
.handleBottomLightOn {
  left:-2px;
  bottom:-30px;
  height:30px;
}
/* setting the light */
.dark {
  background-image:linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.8));
}
.switchLightOn {
  border-top:3px solid rgba(255,255,255,0.1);
  background-image:radial-gradient(rgba(143,12,2,0.5) 0%, transparent 100%),
                   linear-gradient(transparent 10%, rgba(143,12,2,0.7) 50%, transparent 90%),   
                   linear-gradient(#171617, #080808);
  background-size:100% 60%, 84px 100%, 100% 100%;
  background-position:0% 50%, 8px 100%, 0% 100%;
  background-repeat:no-repeat, no-repeat;
  box-shadow:2px 2px 3px rgba(0,0,0,0.3),
             4px 4px 6px rgba(0,0,0,0.2),
             6px 6px 8px rgba(0,0,0,0.2),
             8px 8px 10px rgba(0,0,0,0.1),
             10px 10px 12px rgba(0,0,0,0.1),
             -2px 2px 3px rgba(0,0,0,0.3),
             -4px 4px 6px rgba(0,0,0,0.2),
             -6px 6px 8px rgba(0,0,0,0.2),
             -8px 8px 10px rgba(0,0,0,0.1),
             -10px 10px 12px rgba(0,0,0,0.1),
             0px 15px 14px rgba(0,0,0,0.3),
             0px 20px 14px rgba(0,0,0,0.15);
}
.switchLightOff {
  border-top:3px solid rgba(255,255,255,0.05);
  background-image:linear-gradient(#0a0a0a, #050505);
  background-size:100% 100%;
  background-position:0% 100%;
  background-repeat:no-repeat;
  box-shadow:2px 2px 3px rgba(0,0,0,0.1),
             4px 4px 6px rgba(0,0,0,0.1),
             6px 6px 8px rgba(0,0,0,0.1),
             8px 8px 10px rgba(0,0,0,0.1),
             10px 10px 12px rgba(0,0,0,0.1),
             -2px 2px 3px rgba(0,0,0,0.1),
             -4px 4px 6px rgba(0,0,0,0.1),
             -6px 6px 8px rgba(0,0,0,0.1),
             -8px 8px 10px rgba(0,0,0,0.1),
             -10px 10px 12px rgba(0,0,0,0.1),
             0px 20px 14px rgba(0,0,0,0.02);
}
.holeLightOn {
  border-bottom:3px solid rgba(85,1,0,0.4);
  background-image:linear-gradient(90deg, transparent 0%, rgba(85,1,0,0.6) 15%, rgba(85,1,0,0.6) 85%, transparent 100%),
                   linear-gradient(transparent, rgba(85,1,0,0.3));
  background-size:100% 3px, 100% 100%;
  background-position:0% 0%, 0% 100%;
  background-repeat:no-repeat, no-repeat;
  box-shadow:inset 0px -2px 2px rgba(0,0,0,0.6);
}
.holeLightOff {
  border-bottom:3px solid #0a0706;
}
.handleLightOff {
  background-color:#520800;
  background-image:linear-gradient(rgba(0,0,0,0.8), rgba(0,0,0,0.7)),
                   linear-gradient(45deg, #000 33%, transparent 33%, transparent 100%, #000);
  background-size:100% 100%, 4px 4px;
  background-position:100% 100%, 0% 0%;
  background-repeat:no-repeat, repeat;
  box-shadow:inset 0px -3px 6px rgba(0,0,0,0.5),
             inset 0px -2px 4px 4px rgba(32,6,5,0.8);
}
.handleLightOn {
  background-color:#000;
  background-image:radial-gradient(rgba(0,0,0,0.8) 0%, transparent 80%),
                   linear-gradient(rgba(255,255,255,0), rgba(255,255,255,0.4)),
                   linear-gradient(45deg, #e81c0b 33%, transparent 33%, transparent 100%, #e81c0b),
                   linear-gradient(45deg, rgba(246,248,39, 0.6) 33%, transparent 33%, transparent 100%, rgba(246,248,39, 0.7)),
                   linear-gradient(rgba(0,0,0,0.9), rgba(0,0,0,0.05)),
                   radial-gradient(rgba(246,248,39, 0.9) 0%, #fb320f 60%, transparent 100%);
  background-size:100% 60%, 100% 40%, 4px 4px, 4px 4px, 100% 70%, 100% 100%;
  background-position:0% -100%, 100% 100%, 0% 0%, 0.5% 0.5%, 100% 0%, 0% -10%;
  background-repeat:no-repeat, no-repeat, repeat, repeat, no-repeat, no-repeat;
  border-top:2px solid #bf5f53;
  border-right:2px solid rgba(251,49,10,0.8);
  border-left:2px solid rgba(251,49,10,0.8);
  box-shadow:0px 3px 0px rgba(251,49,10,0.8),
             0px -3px 0px rgba(251,49,10,0.8);
}
.handleLightOn:after {
  content:'';
  position:absolute;
  width:76px;
  height:40%;
  bottom:0px;
  left:-2px;
  background-image:linear-gradient(rgba(255,255,255,0), rgba(255,255,255,0.4)),
                   linear-gradient(rgba(255,255,255,0), rgba(255,255,255,0.4));
  background-size:2px 100%, 2px 100%;
  background-position:0% 0%, 100% 0%;
  background-repeat:no-repeat, no-repeat;
}
.handleTopLightOff {
  background-color:#520800;
  background-image:linear-gradient(rgba(0,0,0,0.7), rgba(255,255,255,0.1));
  box-shadow:inset 0px -8px 8px -10px rgba(255,255,255,0.3),
             inset 0px 1px 6px 2px rgba(0,0,0,0.8),
             inset 0px 1px 2px 1px rgba(0,0,0,0.4);
}
.handleTopLightOn {
  background-color:#520800;
  background-image:linear-gradient(125deg, rgba(0,0,0,0.7) 0%, transparent 80%),
                   linear-gradient(215deg, rgba(0,0,0,0.7) 0%, transparent 80%),
                   linear-gradient(#490b02, #ab2719);
  background-size:30px 10px, 30px 10px, 100% 100%;
  background-position:0% 0%, 100% 0%, 0% 100%;
  background-repeat:no-repeat, no-repeat, no-repeat;
  box-shadow:inset 0px 4px 4px rgba(0,0,0,0.5),
             inset 0px -1px 3px -1px rgba(255,255,255,0.4);
}
.handleTopLightOn:after {
  content:'';
  position:absolute;
  bottom:-84px;
  left:0px;
  width:100%;
  height:80px;
  background-image:linear-gradient(rgba(0,0,0,0.7), transparent),
                   linear-gradient(rgba(0,0,0,0.7), transparent),
                   linear-gradient(90deg, #8c1f05 0%, #de620e 50%, #8c1f05 100%);
  background-size:2px 100%, 2px 100%, 100% 2px;
  background-position:0% 0%, 100% 100%, 0% 0%;
  background-repeat:no-repeat, no-repeat, no-repeat;
  border-top:2px solid #330911;
}
.handleBottomLightOff {
  background:#170301;
  box-shadow:inset 0px 0px 8px 3px rgba(0,0,0,0.8);
}
.handleBottomLightOn {
  background-image:linear-gradient(rgba(255,255,255,0.4), transparent),
                   radial-gradient(#be1f04 0%, #3f0901 80%);
  background-size:100% 3px, 100% 400%;
  background-position:0% 0%, 0% 100%;
  background-repeat:no-repeat, no-repeat;
  box-shadow:inset 0px 3px 5px 0px rgba(0,0,0,0.2),
             inset 0px -1px 4px 0px #f11503;
  border-right:2px solid rgba(251,49,10,0.8);
  border-bottom:2px solid rgba(251,49,10,0.3);
  border-left:2px solid rgba(251,49,10,0.8);
}

/* globals */
body {
  background:url('https://dl.dropboxusercontent.com/u/330966/static/broken_noise.png');
}
html, body {
  height:100%;
}
              
            
!

JS

              
                 $(function() {
  $('.switch').click(function() {
   if( $(".switch").hasClass("switchLightOff") ) {
    $(".switch").removeClass("switchLightOff"),
    $(".switch").addClass("switchLightOn"),
    $("#Wrapper").removeClass("dark"),
    $(".hole").removeClass("holeLightOff"),
    $(".hole").addClass("holeLightOn"),
    $(".handle").removeClass("handleLightOff"),  
    $(".handle").addClass("handleLightOn"),
    $(".sk").addClass("on"),
    $(".handleTop").removeClass("handleTopLightOff"),  
    $(".handleTop").addClass("handleTopLightOn"),
    $(".handleBottom").removeClass("handleBottomLightOff"),
    $(".handleBottom").addClass("handleBottomLightOn"); 
   }
   else
   {
    $(".switch").addClass("switchLightOff"),
    $("#Wrapper").addClass("dark"),
    $(".hole").removeClass("holeLightOn"),   
    $(".hole").addClass("holeLightOff"),  
    $(".handle").removeClass("handleLightOn"),  
    $(".handle").addClass("handleLightOff"), 
    $(".sk").removeClass("on"),  
    $(".handleTop").removeClass("handleTopLightOn"),  
    $(".handleTop").addClass("handleTopLightOff"),
      $(".handleBottom").removeClass("handleBottomLightOn"),
    $(".handleBottom").addClass("handleBottomLightOff");
   }
   });
  });

              
            
!
999px

Console