cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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>
<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>
            
          
!
            
              * {
	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;
}


            
          
!
            
              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
🕑 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