Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create js dom and css material #2

Merged
merged 1 commit into from Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions DOM/css-combinator/index.html
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Home</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div>
<p>p pertama</p>
<p>p kedua</p>
<span>
<p>p ketiga (dalam span)</p>
</span>
<section>
<span>
<p>p keempat (dalam section dan span)</p>
</span>
</section>
</div>
</body>
</html>
7 changes: 7 additions & 0 deletions DOM/css-combinator/styles.css
@@ -0,0 +1,7 @@
div p {
color: red;
}

div>p {
background-color: yellow;
}
20 changes: 20 additions & 0 deletions DOM/css-selector/index.html
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<h1>Mari Bercerita</h1>
<p style="color: green">Halo, ini adalah ceritaku</p>
<p>aku punya 3 hamster</p>
<div>
<div class="hamster">Cheela</div>
<div class="hamster">Chiara</div>
<div class="hamster" id="aio">Aio</div>
</div>
</body>
</html>
15 changes: 15 additions & 0 deletions DOM/css-selector/styles.css
@@ -0,0 +1,15 @@
.hamster {
color: blue;
}

#aio {
background-color: yellow;
}

h1 {
color: pink;
}

div {
border: 1px solid beige;
}
60 changes: 60 additions & 0 deletions DOM/js-dom/index.html
@@ -0,0 +1,60 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Learn HTML</title>
</head>
<body>
<h1 id="title">Hello</h1>
<h3 class="red">my favorite things</h3>
<ul></ul>
<div class="contoh"></div>
<br />
<input type="text" />
<button id="alert_btn">alert!</button>
</body>

<script>
const title = document.querySelector("#title");
title.innerHTML += ", Ilham";

const contoh = document.querySelector(".contoh");
contoh.innerHTML = "<a href='https://google.com'>google</a>";

function createListItem(item) {
let li = document.createElement("li");
li.textContent = item;
li.className = "favorite-item";
return li;
}

const newFav = ["doll", "pikachu", "eevee", "ditto", "sylveon", "staryu"];

const nodes = newFav.map((item) => {
return createListItem(item);
});

const myFavorite = document.querySelector("ul");
myFavorite.append(...nodes);
// ... artinya spread syntax
// spread operator gunanya untuk *unpack* item yang ada

const input = document.querySelector("input");

const alert_btn = document.querySelector("#alert_btn");

alert_btn.addEventListener("click", () => {
const isi = input.value;
alert(isi);
});

input.addEventListener("keyup", (event) => {
if (event.key === "Enter") {
const isi = input.value;
alert(isi);
}
});
</script>
</html>
18 changes: 18 additions & 0 deletions DOM/simple-html/index.html
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Home</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<nav>
<a href="/" aria-current="page">Home</a>
<a href="/page2.html">Other page</a>
</nav>
<main>
<h1>Home page</h1>
</main>
</body>
</html>
18 changes: 18 additions & 0 deletions DOM/simple-html/page2.html
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Other page</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<nav>
<a href="/">Home</a>
<a href="/page2.html" aria-current="page">Other page</a>
</nav>
<main>
<h1>My other page</h1>
</main>
</body>
</html>
46 changes: 46 additions & 0 deletions DOM/simple-html/styles.css
@@ -0,0 +1,46 @@
* {
box-sizing: border-box;
}

body {
margin: 0;
font-family: system-ui, sans-serif;
color: black;
background-color: white;
}

nav {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
padding: 0.5rem;
gap: 0.5rem;
border-bottom: solid 1px #aaa;
background-color: #eee;
}

nav a {
display: inline-block;
min-width: 9rem;
padding: 0.5rem;
border-radius: 0.2rem;
border: solid 1px #aaa;
text-align: center;
text-decoration: none;
color: #555;
}

nav a[aria-current='page'] {
color: #000;
background-color: #d4d4d4;
}

main {
padding: 1rem;
}

h1 {
font-weight: bold;
font-size: 1.5rem;
}