A Pen by Richard Leishman on CodePen.
Created
March 28, 2017 18:31
-
-
Save mrl22/99d3a4a1302ab2e5c8123bd4bf6c9b39 to your computer and use it in GitHub Desktop.
My Age
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div id="age"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var start = new Date('12/20/1984 03:07 AM'); | |
| var timer; | |
| function age() { | |
| var now = new Date(); | |
| var age = now.getTime()-start.getTime(); | |
| var year = (age / 31558859800); | |
| document.getElementById('age').innerHTML = year.toFixed(10); | |
| } | |
| timer = setInterval(age, 30); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @import url('https://fonts.googleapis.com/css?family=Inconsolata'); | |
| #age { | |
| width: 750px; | |
| height: 200px; | |
| text-align: center; | |
| font-size: 96px; | |
| font-family: 'Inconsolata', monospace; | |
| position:absolute; /*it can be fixed too*/ | |
| left:0; right:0; | |
| top:0; bottom:0; | |
| margin:auto; | |
| /*this to solve "the content will not be cut when the window is smaller than the content": */ | |
| max-width:100%; | |
| max-height:100%; | |
| overflow:auto; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment