Skip to content

Instantly share code, notes, and snippets.

@durvalrafael
Created April 5, 2017 12:12
Show Gist options
  • Select an option

  • Save durvalrafael/8eedeafe4926a983f0fafe4fec291cb6 to your computer and use it in GitHub Desktop.

Select an option

Save durvalrafael/8eedeafe4926a983f0fafe4fec291cb6 to your computer and use it in GitHub Desktop.
Whats Color is it ES 2015
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300" rel="stylesheet">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<style>
body {
font-family: 'Roboto', sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background: #009688;
transition: background 500ms ease-in-out;
}
h1{
font-size: 10em;
color: #FFFFFF;
font-weight: 100;
}
</style>
</head>
<body>
<h1>00:00:00</h1>
<script>
class Main {
constructor() {
this.interval();
}
interval() {
setInterval(this.init, 1000);
}
init() {
let d = new Date();
let hour = ("0" + d.getHours()).slice(-2);
let minute = ("0" + d.getMinutes()).slice(-2);
let second = ("0" + d.getSeconds()).slice(-2);
document.body.style.backgroundColor = "#" + hour + minute + second;
document.querySelector("h1").innerHTML = hour + ':' + minute + ':' + second;
return hour + minute + second;
}
}
var main = new Main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment