-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
121 lines (96 loc) · 3.01 KB
/
index.html
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tell me a Joke</title>
<style>
body {
margin: 0;
padding: 0;
background-color: rgb(5, 20, 53);
}
.container {
position: absolute;
top: 50%;
left: 50%;
text-align: center;
width: max-content;
background-color: rgb(16, 16, 141);
transform: translate(-50%, -50%);
padding: 5px 10px;
border-radius: 5px;
}
.container h1 {
color: rgb(18, 206, 206);
font-size: 3.5rem;
font-weight: 900;
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
text-shadow: 1px 1px 3px rgb(181, 210, 214);
}
#joke-box{
display: block;
position: relative;
}
p {
font-size: 16px;
background-color: rgb(127, 255, 244);
font-weight: 900;
text-align: center;
word-wrap: break-word;
line-height: 35px;
margin: 30px 0;
opacity: 0;
padding: 10px;
}
.content-fade {
opacity: 1;
transition: opacity 0.1s;
}
.btn{
display: flex;
margin-left: auto;
padding: 2px 10px;
border: 1px ;
border-radius: 5px;
outline: 0;
color: black;
background-color: green;
font-size: 15px;
font-weight: 550;
}
.btn:hover{
background-color: azure;
color: green;
transition: all ease-in-out .25s;
border: 1px solid blue;
box-shadow: inset 0 0 10px rgb(9, 17, 128);
}
</style>
</head>
<body>
<div class="container" id="outer-box">
<h1>Wanna Read A Joke??</h1>
<div class="content-fade" >
<p id="joke-box" ></p>
</div>
<button type="submit" value="Generate Jokes!" class="btn">Tell me a joke!!</button>
</div>
<script>
let jokeSection = document.getElementById("joke-box")
let jokeBtn = document.querySelector(".btn")
let API =
"https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist,sexist,explicit&type=single";
const acquireJoke = ()=>{
jokeSection.classList.remove("content-fade")
fetch(API)
.then((info)=> info.json())
.then((item)=>{
jokeSection.textContent = `${item.joke}`
jokeSection.classList.add("content-fade")
})
}
jokeBtn.addEventListener("click", acquireJoke);
</script>
</body>
</html>