Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions fetch/programmer-humour/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Programmer Humour</title>
</head>
<body>
<h1>Programmer Humour</h1>
<img id="comic-image" />
<script src="script.js"></script>
</body>
</html>
13 changes: 13 additions & 0 deletions fetch/programmer-humour/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function getImage() {
fetch("https://xkcd.now.sh/?comic=latest")
.then((response) => response.json())
.then((comicImages) => {
console.log(comicImages);
const comicImage = document.getElementById("comic-image");
comicImage.src = comicImages.img;
})
.catch((error) => {
console.log("Error fetching image:", error);
});
}
getImage();
20 changes: 20 additions & 0 deletions fetch/programmer-humour/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
body {
background-color: #fff0f5;
text-align: center;
padding: 40px;
}

h1 {
color: #c85a8e;
font-family: "Brush Script MT", "Segoe Script", cursive;
font-size: 4rem;
margin-bottom: 50px;
}

#comic-image {
display: block;
width: 1000px;
max-width: 90%;
margin: 0 auto 50px;
box-shadow: 0 8px 20px rgba(180, 80, 130, 0.2);
}
Loading