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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div class="page">
  <div class="page__toggle">
    <label class="toggle">
      <input class="toggle__input" type="checkbox" checked>
      <span class="toggle__label">
        <span class="toggle__text">Check Me!</span>
      </span>
    </label>
  </div>
  <div class="page__toggle">
    <label class="toggle">
      <input class="toggle__input" type="checkbox">
      <span class="toggle__label">
        <span class="toggle__text">Check Me!</span>
      </span>
    </label>
  </div>
  <div class="page__toggle">
    <label class="toggle">
      <input class="toggle__input" type="checkbox" disabled>
      <span class="toggle__label">
        <span class="toggle__text">Check Me!</span>
      </span>
    </label>
  </div>  
</div>
<div class="linkedin">
  <div class="linkedin__container">
    <p class="linkedin__text">I'm looking for my fans which I'll give away everything I know. If you're interested then 👉 <a href="https://www.patreon.com/posts/introduction-to-34774556" class="linkedin__link" rel="noopener noreferrer" target="_blank">join to me on Patreon!</a></p>
  </div>
</div>


              
            
!

CSS

              
                
/*
=====
LEVEL 1. CORE STYLES
=====
*/

.toggle{
  --uiToggleSize: var(--toggleSize, 20px);
  --uiToggleIndent: var(--toggleIndent, .4em);
  --uiToggleBorderWidth: var(--toggleBorderWidth, 2px);
  --uiToggleColor: var(--toggleColor, #000);
  --uiToggleDisabledColor: var(--toggleDisabledColor, #868e96);
  --uiToggleBgColor: var(--toggleBgColor, #fff);
  --uiToggleArrowWidth: var(--toggleArrowWidth, 2px);
  --uiToggleArrowColor: var(--toggleArrowColor, #fff);

  display: inline-block;
  position: relative;
}

.toggle__input{
  position: absolute;
  left: -99999px;
}

.toggle__label{
  display: inline-flex;
  min-height: var(--uiToggleSize);
  padding-left: calc(var(--uiToggleSize) + var(--uiToggleIndent));
}

.toggle__input:not(:disabled) ~ .toggle__label{
  cursor: pointer;
}

.toggle__label::before, 
.toggle__label::after{
  content: "";
  box-sizing: border-box;  
  width: 1em;
  height: 1em;
  font-size: var(--uiToggleSize);

  position: absolute;
  left: 0;
  top: 0;
}

.toggle__label:before{
  border: var(--uiToggleBorderWidth) solid var(--uiToggleColor);
  z-index: 2;
}

.toggle__input:disabled ~ .toggle__label::before{
  border-color: var(--uiToggleDisabledColor);
}

.toggle__input:focus ~ .toggle__label::before{
  box-shadow: 0 0 0 2px var(--uiToggleBgColor), 0 0 0px 4px var(--uiToggleColor);
}

.toggle__input:not(:disabled):checked:focus ~ .toggle__label::after{
  box-shadow: 0 0 0 2px var(--uiToggleBgColor), 0 0 0px 4px var(--uiToggleColor);
}

.toggle__input:not(:disabled) ~ .toggle__label::after{
  background-color: var(--uiToggleColor);
  opacity: 0;
}

.toggle__input:not(:disabled):checked ~ .toggle__label::after{
  opacity: 1;
}

.toggle__text{
  margin-top: auto;
  margin-bottom: auto;
}

/*
The arrow size and position depends from sizes of square because I needed an arrow correct positioning from the top left corner of the element toggle
*/

.toggle__text::before{
  content: "";
  box-sizing: border-box;
  width: 0;
  height: 0;
  font-size: var(--uiToggleSize);

  border-left-width: 0;
  border-bottom-width: 0;
  border-left-style: solid;
  border-bottom-style: solid;
  border-color: var(--uiToggleArrowColor);

  position: absolute;
  top: .5428em;
  left: .2em;
  z-index: 3;

  transform-origin: left top;
  transform: rotate(-40deg) skew(10deg);
}

.toggle__input:not(:disabled):checked ~ .toggle__label .toggle__text::before{
  width: .5em;
  height: .25em;
  border-left-width: var(--uiToggleArrowWidth);
  border-bottom-width: var(--uiToggleArrowWidth);
  will-change: width, height;
  transition: width .1s ease-out .2s, height .2s ease-out;
}

/*
=====
LEVEL 2. PRESENTATION STYLES
=====
*/

/* 
The demo skin
*/

.toggle__input:disabled ~ .toggle__label{
  opacity: .24;
  cursor: not-allowed;
}

.toggle__label::before, 
.toggle__label::after{
  border-radius: 2px;
}

/* 
The animation of switching states
*/

.toggle__input:not(:disabled) ~ .toggle__label::before,
.toggle__input:not(:disabled) ~ .toggle__label::after{
  opacity: 1;
  transform-origin: center center;
  will-change: transform;
  transition: transform .2s ease-out;
}

.toggle__input:not(:disabled) ~ .toggle__label::before{
  transform: rotateY(0deg);
  transition-delay: .2s;
}

.toggle__input:not(:disabled) ~ .toggle__label::after{
  transform: rotateY(90deg);
}

.toggle__input:not(:disabled):checked ~ .toggle__label::before{
  transform: rotateY(-90deg);
  transition-delay: 0s;
}

.toggle__input:not(:disabled):checked ~ .toggle__label::after{
  transform: rotateY(0deg);
  transition-delay: .2s;
}

.toggle__text::before{
  opacity: 0;
}

.toggle__input:not(:disabled):checked ~ .toggle__label .toggle__text::before{
  opacity: 1;
  transition: opacity .1s ease-out .3s, width .1s ease-out .5s, height .2s ease-out .3s;
}

/*
=====
LEVEL 3. SETTINGS
=====
*/

.toggle{
  --toggleColor: #690e90;
  --toggleBgColor: #9b59b6;
  --toggleSize: 50px;
}

/*
=====
DEMO
=====
*/

body{
  min-height: 100vh;
  margin: 0;    
  display: flex;
  flex-direction: column;
  
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Open Sans, Ubuntu, Fira Sans, Helvetica Neue, sans-serif;  
  background-color: #9b59b6;
}

.page{
  margin: auto;  
  padding-left: 10px;
  padding-right: 10px;
  order: 1;
}

.page__toggle{
  font-size: 28px;
  font-weight: 700;
  color: #fff;
}

.page__toggle:nth-child(n+2){
  margin-top: 50px;
}


/*
=====
LinkedIn
=====
*/

.linkedin{
  width: 100%;
  background-color: #fff;
  text-align: center;
  
  position: absolute;
  top: 0;
  left: 0;
}

.linkedin__container{
  max-width: 1000px;
  padding: 10px;
  margin-left: auto;
  margin-right: auto;  
}

.linkedin__text{
  margin-top: 0;
  margin-bottom: 0;
}

.linkedin__link{
  color: #ff5c5c;
}
              
            
!

JS

              
                
              
            
!
999px

Console