File tree Expand file tree Collapse file tree 1 file changed +70
-0
lines changed
Expand file tree Collapse file tree 1 file changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+
4+ < head >
5+ < meta charset ="UTF-8 ">
6+ < title > JS + CSS Die</ title >
7+ </ head >
8+
9+ < body >
10+
11+
12+ < div class ="die ">
13+ < div class ="die-container ">
14+ < span id ="number "> 10</ span >
15+ </ div >
16+ </ div >
17+
18+
19+ < style >
20+ html {
21+ background : # 018DED url (http://unsplash.it/1500/1000?image=881&blur=50);
22+ background-size : cover;
23+ font-family : 'helvetica neue' ;
24+ text-align : center;
25+ font-size : 10px ;
26+ }
27+
28+ body {
29+ margin : 0 ;
30+ font-size : 30rem ;
31+ font-family : 'Roboto' ;
32+ color : white;
33+ display : flex;
34+ flex : 1 ;
35+ min-height : 100vh ;
36+ align-items : center;
37+ }
38+
39+ .die {
40+ width : 30rem ;
41+ height : 30rem ;
42+ margin : 50px auto;
43+ position : relative;
44+ padding : 2rem ;
45+ }
46+
47+ .die-container {
48+ position : relative;
49+ width : 100% ;
50+ height : 100% ;
51+ transform : translateY (-3px );
52+ user-select : none;
53+ /* account for the height of the clock hands */
54+ }
55+ </ style >
56+
57+ < script >
58+ const number = document . querySelector ( '#number' ) ;
59+ const generateRandom = event => {
60+ number . innerText = Math . floor ( Math . random ( ) * 20 ) + 1 ;
61+ }
62+
63+
64+ document . addEventListener ( 'keydown' , generateRandom ) ;
65+ document . addEventListener ( 'click' , generateRandom ) ;
66+
67+ </ script >
68+ </ body >
69+
70+ </ html >
You can’t perform that action at this time.
0 commit comments