Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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="browser">
  <div class="browser__header">
    <i></i>
    <i></i>
    <i></i>
  </div>

  <div class="browser__content">
    <h1>International Moose Count Underway</h1>
    <p>The UN-sponsored International Moose Census got off to a flying start today with hopes for an increase in the worldwide moose population compared to last year’s disapointing figures. Among the traditional early reporters were Egypt, returning figures of six moose, a twenty percent increase on 2011’s figures of five, and Uruguay whose moose population remains stable at eleven.</p>

    <p>Historically the only competitor to China in the far eastern moose markets has been Singapore but the tiny island nation is set to report a net loss, expecting a decrease of more than five percent on last year’s 50,000 moose counted. The head of Singapore’s Agency for Agriculture, JingFeng Lau, explained to an incredulous Singaporean parliament yesterday that bad weather had contributed to this season’s poor showing, most notably when a cargo of 150 moose were swept out into the Indian ocean in a monsoon.</p>
  </div>
  
  <div class="toggle">
    <input type="checkbox" id="toggle">
    <label for="toggle" />
  </div>

</div>
              
            
!

CSS

              
                :root {
  --background: white;
  --text: black;
}

body {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.browser {
  max-width: 750px;
  width: 95%;
  border-radius: 12px;
  max-height: 650px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 1px 1px black;
}

.browser__header {
  padding: 15px;
  position: relative;
  
  &::after {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: black;
    content: "";
  }
}

.browser__header i {
  display: inline-block;
  vertical-align: middle;
  width: 10px;
  height: 10px;
  border-radius: 100px;
  margin-right: 5px;
  border: 1px solid black;
  
  &:nth-child(1) {
    background: #E85D75;
  }
  
  &:nth-child(2) {
    background: #EEC643;
  }
  
  &:nth-child(3) {
    background: #79B791;
  }
}

.browser__content {
  padding: 20px;
  padding-bottom: 5vh;
}

.browser h1,
.browser p {
  color: var(--text);
  transition: color 200ms linear 100ms;
}

.browser__content p {
  line-height: 1.5;
}

.toggle {
  position: absolute;
  top: 14px;
  right: 15px;
}

.toggle label {
  position: relative;
  display: block;
  width: 50px;
  height: 22px;
  background: #fff;
  border: 1px solid var(--text);
  border-radius: 100px;
  cursor: pointer;
  
  &::before {
    position: absolute;
    width: 900px;
    height: 900px;
    background: var(--background);
    z-index: 10;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    border-radius: 100%;
    opacity: 1;
    transform: translate3d(-47%, 0, 0) scale(0.1);
    transition: background 300ms ease-in-out 200ms, opacity 350ms ease-in-out 200ms, transform 400ms ease-in-out;
    pointer-events: none;
    content: "";
    opacity: 0;
    z-index: -999;
  }
  
  &::after {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 4px;
    margin: auto;
    width: 14px;
    height: 14px;
    background: #fff;
    border: 1px solid black;
    content: "";
    border-radius: 100px;
    transition: background 200ms linear,
      transform 200ms ease-in-out 100ms;
  }
}

.toggle input {
  display: none;
  
  &:checked {
    ~ label:after {
      background: #000;
      transform: translate3d(27px, 0, 0);
    }
    
    ~ label:before {
      transform: translate3d(-84%, 23%, 0) scale(1);
      transition: background 300ms ease-in-out, opacity 30ms ease-in-out, transform 400ms ease-in-out;
      opacity: 1;
    }
  }
}
              
            
!

JS

              
                const toggle = document.querySelector('.toggle');
let root = document.documentElement;

toggle.addEventListener('change', e => {
  if (e.target.checked) {
    root.style.setProperty('--background', 'black');
    root.style.setProperty('--text', 'white');
  } else {
    root.style.setProperty('--background', 'white');
    root.style.setProperty('--text', 'black');
  }
})
              
            
!
999px

Console