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

              
                <header class="header" role="banner">
  <span class="logo">
   <span class="logo__move">FF</span>
  </span>
  <label class="toggle-theme">
    <input class="toggle-theme__control "type="checkbox"> 
    <span class="toggle-theme__track">Trocar tema</span>
  </label>
</header>

<article class="content">
  <h1>CSS Variables are awesome!</h1>
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Qui numquam magni architecto earum nam magnam nulla deleniti officia quibusdam eius, amet perferendis laborum aliquam accusamus et dolore porro minus doloribus.</p>
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptatibus unde corrupti consequuntur nostrum, recusandae aliquid expedita quas blanditiis nam quidem culpa, molestias sed magnam incidunt non? Doloribus hic animi at.</p>
</article>
              
            
!

CSS

              
                :root {
  --space-xxs: 4px;
  --space-xs: 8px;
  --space-sm: 16px;
  --space: 24px;
  --space-md: 32px;
  --space-lg: 48px;
  --space-xlg: 64px;

  --screen-sm: 768px;

  --gray: #555;
  --gray-dark: #333;
  --gray-darker: #111;
  --gray-light: #f1f1f1;
  --gray-lighter: #fafafa;
  --blue: #187888;
  --yellow: #e6af05;
  --white: #fff;
  --black: #000;

  --brand-primary: var(--blue);
  --background: var(--white);
  --background-header: var(--gray-light);
  --text-color: var(--gray-darker);
  
  --move-x: var(--space);
  --move-y: var(--space-sm);
}

body {
  background-color: var(--background);
  color: var(--text-color);
  font-family: "Open Sans", sans-serif;
  transition: background-color .25s;
  will-change: background-color;
  
  &.theme-dark {
    --background: var(--black);
    --background-header: var(--gray-darker);
    --text-color: var(--gray-lighter);
    --brand-primary: var(--yellow);
  }
  
  @media (max-width: 768px) {
    --background: var(--black);
    --text-color: var(--white);
  }
}

.header {
  align-items: center;
  background-color: var(--background-header);
  border-bottom: solid var(--space-xxs) var(--brand-primary);
  display: flex;
  height: var(--space-xlg);
  justify-content: space-between;
  padding-left: var(--space);
  padding-right: var(--space);
  transition: background-color .25s;
  will-change: background-color;
}

.logo {
  color: var(--brand-primary);
  font-size: 30px;
  font-weight: bold;
  
  &__move {
    left: var(--move-x);
    position: fixed;
    top: var(--move-y);
  }
}

.toggle-theme {
  align-items: center;
  background-color: var(--gray);
  border-radius: var(--space);
  display: flex;
  justify-content: space-between;
  height: var(--space);
  position: relative;
  width: 50px;
  
  &:before,
  &:after {
    font-size: 18px;
  }
  
  &:before {
    content: "🌜";
  }
  
  &:after {
    content: "🌞";
  }
  
  &__track {
    background-color: var(--gray-lighter);
    border: var(--gray) solid 1px;
    border-radius: 50%;
    height: var(--space);
    position: absolute;
    text-indent: -999em;
    transition: transform .25s;
    width: var(--space);
  }
  
  &__control {
    opacity: 0;
    position: absolute;
    top: -999em;
    
    &:checked {
      & ~ .toggle-theme__track {
        transform: translateX(100%) 
      }
    }
  }
}

.content {
  margin-left: auto;
  margin-right: auto;
  max-width: var(--screen-sm);
  padding: var(--space);
  
  > h1 {
    font-size: 30px;
    
    &:not(:last-child) {
      margin-bottom: var(--space);
    }
  }
  
  > p {
    &:not(:last-child) {
      margin-bottom: var(--space);
    }
  }
}
              
            
!

JS

              
                const $body = document.body
const $toggleButton = document.querySelector('.toggle-theme__control')
$toggleButton.addEventListener('change', toggleTheme, false)

function toggleTheme(e) {
 return e.target.checked 
 	? $body.className = 'theme-dark' 
	: $body.className = 'theme-light'
}

$body.addEventListener('mousemove', (e) => {
  $body.style.setProperty('--move-x', `${e.clientX}px`)
  $body.style.setProperty('--move-y', `${e.clientY}px`)
})

              
            
!
999px

Console