Skip to content

Instantly share code, notes, and snippets.

@maztch
Created October 7, 2016 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maztch/d60c6f8679ca1bbd466b8359ebca8418 to your computer and use it in GitHub Desktop.
Save maztch/d60c6f8679ca1bbd466b8359ebca8418 to your computer and use it in GitHub Desktop.
ligth-css
<script>
window.addEventListener('devicelight', function(e) {
var lux = e.value;
if (lux < 50) { // luz tenue
document.body.className = 'tenue';
}
if (lux >= 50 && lux <= 1500) { //luz normal
document.body.className = 'normal';
}
if (lux > 1500) { // mucha luz
document.body.className = 'luminoso';
}
});
</script>
<style>
body,
body.normal {
/*fondo de luminosidad media*/
background-color: #963F53;
/*letra de color
levemente oscuro*/
color: #111;
}
body.tenue {
/*fondo oscuro
para ambiente de oscuridad*/
background-color: #70011B;
/*luz clara que resalte del fondo*/
color: #fff;
}
body.luminoso {
/*fondo claro
para ambiente de mucha claridad*/
background-color: #fff;
/*luz oscura que resalte del fondo*/
color: #70011B;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment