css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <form method="get">
  <input type="checkbox" name="mode" id="mode" value="night" onclick="modecheck()">
  <label for="mode">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 333.3 169">
	<path id="Peanut" d="M115,17.3c13.9,5.4,30.7,9.8,49.4,9.8 c18.8,0,36.1-3.7,49.7-10c9-4,19-6.3,29.5-6.3c40,0,72.4,32.4,72.4,72.4s-32.4,72.4-72.4,72.4c-10.7,0-20.8-2.3-30-6.5h-0.1 c-13.6-6.1-30.7-9.8-49.4-9.8c-18.4,0-35.4,3.6-48.8,9.6l0,0c-9.1,4.1-19.2,6.4-29.9,6.4C45.5,155.4,13,123,13,83 s32.4-72.4,72.4-72.4C98.7,10.6,105.3,13.5,115,17.3z" />
</svg>
	<span class="initial"></span>
	<span class="follower"></span>
  </label>
</form>
<section>
  <h1>From The Earth To The Moon</h1>
  <h2><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jules-verne-autograph.svg" alt="Jules Verne" class="switch"></h2>
  <h3><span>Chapter I</span>The Gun Club</h3>
<p>During the War of the Rebellion, a new and influential club was established in the city of Baltimore in the State of Maryland. It is well known with what energy the taste for military matters became developed among that nation of ship-owners, shopkeepers, and mechanics. Simple tradesmen jumped their counters to become extemporized captains, colonels, and generals, without having ever passed the School of Instruction at West Point; nevertheless; they quickly rivaled their compeers of the old continent, and, like them, carried off victories by dint of lavish expenditure in ammunition, money, and men.</p>

<p><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/earth-moon-sun-system.png" id="diagram" alt="Diagram of Earth-Moon-Sun system">But the point in which the Americans singularly distanced the Europeans was in the science of gunnery. Not, indeed, that their weapons retained a higher degree of perfection than theirs, but that they exhibited unheard-of dimensions, and consequently attained hitherto unheard-of ranges. In point of grazing, plunging, oblique, or enfilading, or point-blank firing, the English, French, and Prussians have nothing to learn; but their cannon, howitzers, and mortars are mere pocket-pistols compared with the formidable engines of the American artillery.</p>

<p>This fact need surprise no one. The Yankees, the first mechanicians in the world, are engineers-- just as the Italians are musicians and the Germans metaphysicians-- by right of birth. Nothing is more natural, therefore, than to perceive them applying their audacious ingenuity to the science.</p>

</section>


            
          
!
            
              @font-face {
    font-family: 'IM Fell French Canon Pro';
    src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/im-fell-french-canon-pro.woff2') format('woff2'),
         url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/im-fell-french-canon-pro.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}
@keyframes sideslide {
		0% { 
      transform: translateX(0%) scale(1); 
  }
		50% { 
      transform: translateX(67%) scale(.75); 
  }
		100% { 
      transform: translateX(134%) scale(1); 
      background: white;
  }		
	}

body { 
  font-family: IM Fell French Canon Pro, script;
  margin: 3rem;
}

label[for="mode"] { 
    display: block;
		padding-top: 10%;
		width: 10%;
    min-width: 100px;
		position: relative;
	}
label[for="mode"]:hover {
  cursor: pointer;
}
	label[for="mode"] svg { 
		position: absolute; 
		top: 0;
		fill: #b7eaff;
		transition: .8s;
	}
  label[for="mode"] span {
		position: absolute;
		display: block;
		width: 35%;
		height: 35%;
		background: yellow;
		top: 7%;
		left: 8%;
		border-radius: 50%;
	}
#mode { display: none; }
#mode:checked + label span {
		animation: sideslide .8s forwards;
	}
#mode:checked + label span.follower {
		animation-delay: .07s;
	}
#mode:checked + label svg {
		fill: #191621;
    stroke-width: 1px;
    stroke: white;
	}
section { 
  max-width: 40rem;
  line-height: 1.4;
  margin: 0 auto;
  h1 {
    font-size: 3rem;
    margin-top: -3rem;
  }
  h2 {
    text-align: center;
    margin: 0;
  img {
    width: 50%;
    min-width: 200px;
  }
  }
  h3 { 
    font-size: 2.3rem;
    text-align: center;
    span {
      display: block;
      &:after {
        content: ":";
      }
    }
  }
  p {
      font-size: 1.4rem;
  }
  #diagram {
    float: right;
    margin-left: 3rem;
    width: 17.8rem;
    @media all and (max-width: 600px) {
      float: none;
      display: block;
      width: 75%;
      margin: 0 auto;
    }
  }
}
body { 
  transition: 2s background, color; }
.night {
  body { 
    background: #000; 
    color: #fff;
  }
  img.switch { 
    filter: invert(100%);
  }
  
}
@media (light-level: dim) {
  // from CSS Luminosity Media Queries: https://drafts.csswg.org/mediaqueries4/#luminosity
  // currently only supported in FF
  body { 
    background: #000; 
    color: #fff;
  }
  img.switch { 
    filter: invert(100%);
  }
}
            
          
!
            
              var mode = document.getElementById("mode");
var lux;
window.addEventListener('devicelight', function(e) {
  lux = e.value;
  // AmbientLight API - not well-supported right now
})
var currentTime = new Date().getHours();

function modecheck() {
  if (mode.checked) {
 document.documentElement.classList.add('night');
  } else {
 document.documentElement.classList.remove('night'); 
  }
}

function timeCheck() {
  if (currentTime > 18 || currentTime < 6 || lux < 50) {
      mode.checked = true;
  }
}

function callEveryHour() {
    setInterval(timeCheck(), 1000 * 60 * 60);
}
timeCheck();
modecheck();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console