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

              
                Original Toggle: https://codepen.io/desaraev/pen/yJepXR

<div class='showit'>
  <div class='starstwinkle'/>
<div class='twinkling'/>
<div class='clouds'/>
</div> <!--for star theme-->

<!--start the toggle: the toggle is based on checkbox toggling-->
<!--note that the JS in this code just changes the class in the body based on the toggle-->
  <div class="toggle toggledaynight">
   <input class="togglecheckbox" id="toggledaynight" type="checkbox">
   <label class="togglebtn" for="toggledaynight"><span class="togglefeature"></span></label>
  </div>
              
            
!

CSS

              
                /****************************DAY NIGHT TOGGLE *************************/
*,
*::before,
*::after {
  box-sizing: border-box;
}

.toggle {
  display: block;
  text-align: center;
  user-select: none;
    position: fixed;
    bottom: 0;
    z-index: 11111;
}

.togglecheckbox {
  display: none;
}

.togglebtn {
  display: block;
  margin: 0 auto;
  font-size: 1.4em;
  transition: all 350ms ease-in;
}
.togglebtn:hover {
  cursor: pointer;
}

.togglebtn, .togglebtn:before, .togglebtn:after,
.togglecheckbox,
.togglecheckbox:before,
.togglecheckbox:after,
.togglefeature,
.togglefeature:before,
.togglefeature:after {
  transition: all 250ms ease-in;
}
.togglebtn:before, .togglebtn:after,
.togglecheckbox:before,
.togglecheckbox:after,
.togglefeature:before,
.togglefeature:after {
  content: &#39;&#39;;
  display: block;
}

/* ===================================================
   Day/Night and Gender toggle buttons
   =================================================== */
.toggledaynight .togglebtn,
.togglelike .togglebtn {
  position: relative;
  height: 53px;
  width: 125px;
  border-radius: 70px;
}
.toggledaynight .togglebtn:before,
.togglelike .togglebtn:before {
  position: absolute;
    top: 0px;
    left: 4px;
    width: 52px;
    height: 44px;
  border-radius: 50%;
}

.toggledaynight .togglebtn {
  border: 5px solid #1c1c1c;
  background-color: #3c4145;
}
.toggledaynight .togglebtn:before {
  background-color: #fff;
  border: 5px solid #e3e3c7;
}
.toggledaynight .togglebtn:after {
  position: absolute;
  top: 62%;
  left: 39px;
  z-index: 10;
  width: 11.2px;
  height: 11.2px;
  opacity: 0;
  background-color: #fff;
  border-radius: 50%;
  box-shadow: #fff 0 0, #fff 3px 0, #fff 6px 0, #fff 9px 0, #fff 11px 0, #fff 14px 0, #fff 16px 0, #fff 21px -1px 0 1px, #fff 16px -7px 0 -2px, #fff 7px -7px 0 1px, #d3d3d3 0 0 0 4px, #d3d3d3 6px 0 0 4px, #d3d3d3 11px 0 0 4px, #d3d3d3 16px 0 0 4px, #d3d3d3 21px -1px 0 5px, #d3d3d3 16px -7px 0 1px, #d3d3d3 7px -7px 0 5px;
  transition: opacity 100ms ease-in;
}
@keyframes starry_star {
  50% {
    background-color: rgba(255, 255, 255, 0.1);
    box-shadow: #fff 30px -3px 0 0, #fff 12px 10px 0 -1px, rgba(255, 255, 255, 0.1) 38px 18px 0 1px, #fff 32px 34px 0 0, rgba(255, 255, 255, 0.1) 20px 24px 0 -1.5px, #fff 5px 38px 0 1px;
  }
}
@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 100;
    transform: scale(1.1);
  }
  55% {
    transform: scale(1.1);
  }
  75% {
    transform: scale(0.9);
  }
  100% {
    opacity: 100;
    transform: scale(1);
  }
}
.toggledaynight .togglefeature {
  display: block;
  position: absolute;
  top: 9px;
  left: 52.5%;
  z-index: 20;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: #fff;
  box-shadow: rgba(255, 255, 255, 0.1) 30px -3px 0 0, rgba(255, 255, 255, 0.1) 12px 10px 0 -1px, #fff 38px 18px 0 1px, rgba(255, 255, 255, 0.1) 32px 34px 0 0, #fff 20px 24px 0 -1.5px, rgba(255, 255, 255, 0.1) 5px 38px 0 1px;
  animation: starry_star 5s ease-in-out infinite;
}
.toggledaynight .togglefeature:before {
  position: absolute;
  top: -2px;
  left: -25px;
  width: 18px;
  height: 18px;
  background-color: #fff;
  border-radius: 50%;
  border: 5px solid #e3e3c7;
  box-shadow: #e3e3c7 -28px 0 0 -3px, #e3e3c7 -8px 24px 0 -2px;
  transform-origin: -6px 130%;
}
.toggledaynight .togglecheckbox:checked + .togglebtn {
  background-color: #9ee3fb;
  border: 5px solid #86c3d7;
}
.toggledaynight .togglecheckbox:checked + .togglebtn:before {
  left: 55px;
  background-color: #ffdf6d;
  border: 5px solid #e1c348;
}
.toggledaynight .togglecheckbox:checked + .togglebtn:after {
  opacity: 100;
  animation-name: bounceIn;
  animation-duration: 0.60s;
  animation-delay: 0.10s;
  animation-fill-mode: backwards;
  animation-timing-function: ease-in-out;
}
.toggledaynight .togglecheckbox:checked + .togglebtn &gt; .togglefeature {
  opacity: 0;
  box-shadow: rgba(255, 255, 255, 0.1) 30px -3px 0 -4px, rgba(255, 255, 255, 0.1) 12px 10px 0 -5px, #fff 38px 18px 0 -3px, rgba(255, 255, 255, 0.1) 32px 34px 0 -4px, #fff 20px 24px 0 -5.5px, rgba(255, 255, 255, 0.1) 5px 38px 0 -3px;
  animation: none;
}
.toggledaynight .togglecheckbox:checked + .togglebtn &gt; .togglefeature:before {
  left: 25px;
  transform: rotate(70deg);
}


#toggledaynight {
  display:none;
}
label:hover{
  opacity:0.8;
}
#toggledaynight:checked ~ div img{
  opacity:0;
}
.showit {
  display:none;
}

              
            
!

JS

              
                <script>
(function() {
  var $check = $(&quot;input[type=&#39;checkbox&#39;]&quot;);
  var $label = $(&quot;.togglebtn&quot;);
  var $body = $(&quot;body&quot;);
  var $a = $(&quot;a&quot;);
  var $mainbg = $(&quot;div[class=&#39;mainbg&#39;]&quot;);

  $check.on(&quot;click&quot;, function() {
    var $this = $(this);
    if ($this.hasClass(&quot;checked&quot;)) {
      $this.removeClass(&quot;checked&quot;).val(&quot;false&quot;);
      $this.removeAttr(&quot;checked&quot;);
	  $body.addClass(&quot;magicbg&quot;);
	  $body.removeClass(&quot;darkbg&quot;);
	  $mainbg.removeClass(&quot;mainbg&quot;);
      $label.animate({
        color: &quot;#FFF&quot;
      }, 500);
      $a.animate({
        color: &quot;#FFF&quot;
      }, 500);
    } else {
      $this.addClass(&quot;checked&quot;).val(&quot;true&quot;);
      $this.attr(&quot;checked&quot;, &quot;checked&quot;);
	  $body.addClass(&quot;darkbg&quot;);
	  $body.removeClass(&quot;magicbg&quot;);
	  $mainbg.removeClass(&quot;mainbg&quot;);
      $label.animate({
        color: &quot;#FFF&quot;
      }, 500);
      $a.animate({
        color: &quot;#558FC1&quot;
      }, 500);
    }
  });
  }.call(this));</script> 
              
            
!
999px

Console