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

              
                <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width"/>
<link href='https://fonts.googleapis.com/css?family=Give+You+Glory' rel='stylesheet' type='text/css'> 
</head>

<body>
<h2>Responsive UI with Ambient Light Events</h2>
<h1>Demo</h1>
<p>Sensor value:<br>
<span id="result">AmbientLightEvent is not supported</span></p>
    
<p>Sensor value in string:<br>
<span id="resultLevel">LightLevelEvent is not supported</span></p>

<p>
  <img src="http://placekitten.com/300/160"/>
</p>
  
  <p>I finally wrote up an article about this demo: <a href="http://girliemac.com/blog/2014/01/12/luminosity/">girliemac.com/blog/2014/01/12/luminosity/</a>
  </p>
<p>
  Kitty ipsum dolor sit amet, lay down in your way lay down in your way lick puking run, eat jump climb the curtains toss the mousie I don’t like that food eat. Zzz catnip sleep in the sink lay down in your way, claw zzz lay down in your way attack meow catnip. Knock over the lamp climb the curtains attack your ankles eat the grass, sniff climb the curtains fluffy fur judging you attack chuf chase the red dot.
</p>
<p>Kitty ipsum dolor sit amet, lay down in your way lay down in your way lick puking run, eat jump climb the curtains toss the mousie I don’t like that food eat. Zzz catnip sleep in the sink lay down in your way, claw zzz lay down in your way attack meow catnip. Knock over the lamp climb the curtains attack your ankles eat the grass, sniff climb the curtains fluffy fur judging you attack chuf chase the red dot.
</p>
  
  <p>
    Tail flick stuck in a tree lick sunbathe scratched attack your ankles, lick litter box litter box puking hiss. Attack zzz toss the mousie run climb the curtains, sleep on your keyboard litter box chase the red dot sleep in the sink lick zzz claw. Stuck in a tree kittens sleep on your keyboard lick run, knock over the lamp hiss zzz sleep on your keyboard feed me meow jump. Stretching catnip stuck in a tree scratched, run stuck in a tree stuck in a tree lick feed me sleep in the sink tail flick bat. Rip the couch scratched eat hiss, I don't like that food eat claw lay down in your way bat scratched climb the curtains biting. Puking stuck in a tree meow attack judging you, sleep in the sink give me fish stretching rip the couch purr fluffy fur.
  </p>
</body>
</html>
              
            
!

CSS

              
                * {
	box-sizing: border-box;
}
html, input {
    font-family: "Segoe UI Web Light", "Segoe UI Light", "Segoe UI Web Regular", "Segoe UI", "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; 
}
html {
    -ms-text-size-adjust: none;
}
html, body {
	padding: 0;
	margin: 1em;
	height: 100%;
}
body,
body.normal {
  /* default in mormal luminosity level */
  background-color: #d7d7d7;
  color: #111;
}
body.dim {
  background-color: #444;
  color: #fff;
}
body.bright {
  background-color: #fff;
  color: #333;
}
a {
	color: green;
}
header {
	margin-bottom: 1em;
}
h1, h2, h3 {
	margin: 0;
	font-weight: normal;
}
h1 {
	font-size: 3.375rem;
	text-transform: lowercase;
}
h2 {
	font-size: 1rem;
	text-transform: uppercase;
}

#result, #resultLevel {
  color: red;
}


              
            
!

JS

              
                window.addEventListener('devicelight', function(e) {
  var lux = e.value;
  document.querySelector('#result').textContent = lux + ' lux';
  
  if(lux < 50) {
    document.body.className = 'dim';
  }
  if(lux >= 50 && lux <= 1000) {
    document.body.className = 'normal';
  }
  if(lux > 1000)  {
    document.body.className = 'bright';
  }
  
});

window.addEventListener('lightlevel', function(e) {
  var level = e.value; document.querySelector('#resultLevel').textContent = level;
  
  if(level === 'dim') {
    document.body.className = 'dim';
  }
  if(level === 'normal')  {
    document.body.className = 'normal';
  }
  if(level === 'bright')  {
    document.body.className = 'bright';
  }
});
              
            
!
999px

Console