File tree Expand file tree Collapse file tree 3 files changed +83
-7
lines changed
Expand file tree Collapse file tree 3 files changed +83
-7
lines changed Original file line number Diff line number Diff line change 1- <!DOCTYPE html>
1+ <!doctype html>
22< html lang ="en ">
33 < head >
44 < meta charset ="UTF-8 " />
55 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6- < title > Title here </ title >
6+ < title > Quote Generator </ title >
77 < script defer src ="quotes.js "> </ script >
88 </ head >
99 < body >
10- < h1 > hello there</ h1 >
11- < p id ="quote "> </ p >
12- < p id ="author "> </ p >
13- < button type ="button " id ="new-quote "> New quote</ button >
10+ < div class ="container ">
11+ < h1 > Quote Generator</ h1 >
12+ < p id ="quote "> </ p >
13+ < p id ="author "> </ p >
14+ < button type ="button " id ="new-quote "> New quote</ button >
15+ </ div >
1416 </ body >
1517</ html >
Original file line number Diff line number Diff line change 1+ const quoteElement = document . querySelector ( "#quote" ) ;
2+ const authorElement = document . querySelector ( "#author" ) ;
3+ const button = document . querySelector ( "#new-quote" ) ;
4+
5+ function showQuote ( ) {
6+ const index = Math . floor ( Math . random ( ) * quotes . length ) ;
7+ const randomQuote = quotes [ index ] ;
8+
9+ quoteElement . innerText = randomQuote . quote ;
10+ authorElement . innerText = randomQuote . author ;
11+ }
12+
13+ button . addEventListener ( "click" , showQuote ) ;
14+
15+ window . onload = showQuote ;
16+
117// DO NOT EDIT BELOW HERE
218
319// pickFromArray is a function which will return one item, at
Original file line number Diff line number Diff line change 1- /** Write your CSS in here **/
1+ body {
2+ margin : 0 ;
3+ height : 100vh ;
4+ background-color : # f59e0b ;
5+ display : flex;
6+ justify-content : center;
7+ align-items : center;
8+ font-family : Georgia, serif;
9+ }
10+
11+ .container {
12+ background-color : # e5e5e5 ;
13+ padding : 50px ;
14+ width : 70% ;
15+ max-width : 800px ;
16+ border-radius : 6px ;
17+ }
18+
19+ h1 {
20+ font-size : 1.5rem ;
21+ margin-bottom : 30px ;
22+ }
23+
24+ # quote {
25+ font-size : 1.6rem ;
26+ color : # f59e0b ;
27+ line-height : 1.6 ;
28+ }
29+
30+ # quote ::before {
31+ content : "❝" ;
32+ font-size : 3rem ;
33+ margin-right : 10px ;
34+ vertical-align : middle;
35+ }
36+
37+ # author {
38+ text-align : right;
39+ margin-top : 20px ;
40+ color : # f59e0b ;
41+ font-size : 1.2rem ;
42+ }
43+
44+ button {
45+ display : block;
46+ margin-left : auto;
47+ margin-top : 25px ;
48+ background-color : # f59e0b ;
49+ color : white;
50+ border : none;
51+ padding : 12px 24px ;
52+ font-size : 1rem ;
53+ cursor : pointer;
54+ border-radius : 4px ;
55+ }
56+
57+ button : hover {
58+ background-color : # d97706 ;
59+ }
You can’t perform that action at this time.
0 commit comments