Skip to content

Commit 6dd8e88

Browse files
authored
Add files via upload
0 parents  commit 6dd8e88

File tree

5 files changed

+99
-0
lines changed

5 files changed

+99
-0
lines changed

images/dog.png

225 KB
Loading

images/dog2.png

202 KB
Loading

index.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!doctype html>
2+
<html lang="en-US">
3+
<head>
4+
<link href="styles/style.css" rel="stylesheet" />
5+
<link rel="preconnect" href="https://fonts.googleapis.com">
6+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
7+
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
8+
<meta charset="utf-8" />
9+
<meta name="viewport" content="width=device-width" />
10+
<title>My test page</title>
11+
<script async src="scripts/main.js"></script>
12+
</head>
13+
<body>
14+
<h1>Kinds Of Dogs</h1>
15+
<img src="images/dog.png" alt="dog image" />
16+
<p>There are many different kinds of dogs.</p>
17+
<ul>
18+
<li>Beagle</li>
19+
<li>Bulldog</li>
20+
<li>Chihuahua</li>
21+
<li>Dachshund</li>
22+
<li>German Shepherd</li>
23+
</ul>
24+
<p>If you want to know more about kinds of dogs, visit this <a href="https://blog.naver.com/splk4567/221661873057">website</a>.</p>
25+
<button>Change user</button>
26+
</body>
27+
</html>

scripts/main.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const myImage = document.querySelector("img");
2+
3+
myImage.addEventListener("click", () => {
4+
const mySrc = myImage.getAttribute("src");
5+
if (mySrc === "images/dog.png") {
6+
myImage.setAttribute("src", "images/dog2.png");
7+
} else {
8+
myImage.setAttribute("src", "images/dog.png");
9+
}
10+
});
11+
12+
let myButton = document.querySelector("button");
13+
let myHeading = document.querySelector("h1");
14+
15+
function setUserName() {
16+
const myName = prompt("Please enter your name.");
17+
if (!myName) {
18+
setUserName();
19+
} else {
20+
localStorage.setItem("name", myName);
21+
myHeading.textContent = `Kinds Of Dogs, ${myName}`;
22+
}
23+
}
24+
25+
if (!localStorage.getItem("name")) {
26+
setUserName();
27+
} else {
28+
const storedName = localStorage.getItem("name");
29+
myHeading.textContent = `Kinds Of Dogs, ${storedName}`;
30+
}
31+
32+
myButton.addEventListener("click", () => {
33+
setUserName();
34+
});

styles/style.css

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
html {
2+
/* px means "pixels". The base font size is now 10 pixels high */
3+
font-size: 10px;
4+
/* Replace PLACEHOLDER with the font-family property value you got from Google Fonts */
5+
font-family: "Montserrat", sans-serif;
6+
background-color: #eaeaea;
7+
}
8+
9+
h1 {
10+
font-size: 60px;
11+
text-align: center;
12+
margin: 0;
13+
padding: 20px 0;
14+
color: #eaeaea;
15+
text-shadow: 3px 3px 1px black;
16+
}
17+
18+
p,
19+
li {
20+
font-size: 16px;
21+
line-height: 2;
22+
letter-spacing: 1px;
23+
}
24+
25+
body {
26+
width: 600px;
27+
margin: 0 auto;
28+
background-color: #ff9500;
29+
padding: 0 20px 20px 20px;
30+
border: 5px solid black;
31+
}
32+
33+
img {
34+
display: block;
35+
margin: 0 auto;
36+
max-width: 100%;
37+
}
38+

0 commit comments

Comments
 (0)