-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDadjokeAPI.html
More file actions
107 lines (90 loc) · 2.46 KB
/
DadjokeAPI.html
File metadata and controls
107 lines (90 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
height: 100vh;
background: linear-gradient(rgb(69, 178, 252), rgb(19, 42, 255), rgb(46, 9, 253));
}
#container {
position: relative;
top: 10%;
left: 10%;
flex-direction: column;
height: 70%;
width: 80%;
background: #000;
color: white;
font-family: sans-serif;
display: flex;
justify-content: center;
align-items: center;
}
h1 {
position: relative;
font-size: 10vh;
margin: auto;
text-transform: uppercase;
display: inline-block;
text-shadow: 0px 0px 5px cyan;
}
.btn {
margin-top: 20vh;
position: relative;
top:-20%;
padding:20px 50px;
border: none;
outline: none;
font-size: 0.85rem;
text-transform: uppercase;
font-weight: bold;
border: 1px solid black;
box-shadow: inset 0px 0px 5px cyan,
inset 0px 0px 15px black;
transition: all 500ms;
}
.btn:hover {
box-shadow: inset 1px 1px 15px cyan,
inset 0px 0px 25px black;
}
#content{
margin: auto;
border: 1px red;
padding: 4vh;
font-size: 1.2rem;
max-width: 700px;
margin-top: 20px;
}
</style>
</head>
<body>
<div id="container">
<h1>Dad Jokes</h1>
<button id="btn" class="btn">Get Joke</button>
<div id="content"></div>
</div>
<script>
document.getElementById("btn").addEventListener("click", joke)
async function joke(){
let config ={
headers:{
Accept:"application/json",
},
};
let a = await fetch("https://icanhazdadjoke.com/",config);
let b = await a.json();
console.log(b)
document.getElementById("content")
.innerHTML = b.joke;
}
</script>
</body>
</html>