Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Basics</title>
<link rel="stylesheet" href="styles.css">
</head>

<body>
<header>
<h1>JavaScript Basics</h1>
</header>
<main>
<section class="section">
<div class="smile-content">
<button id="smile-button">Touch me</button>
<h3 id="smile"></h3>
</div>
</section>
<section class="section">
<h3 class="sum-title">Sum two numbers</h3>
<div class="section-content">
<div class="sum-content">
<label>Type number one</label>
<input type="number" id="num-1">
</div>
<div class="sum-content">
<label>Type number two</label>
<input type="number" id="num-2">
</div>
</div>
<button id="result-button">Sum +</button>
<h3 id="result"></h3>
</section>
</main>

<script>
document.querySelector('#smile-button').addEventListener('click', function () {
let name = prompt('Type your name!');
document.getElementById('smile').innerHTML = `Welcome <span>${name}</span>, nice to meet you! 😊`;
});

document.querySelector('#result-button').addEventListener('click', function () {
let num1 = document.getElementById('num-1').value;
let num2 = document.getElementById('num-2').value;
let result = parseInt(num1) + parseInt(num2);
document.getElementById('result').innerHTML = `Rresult is: <span>${result}</span>`;
})
</script>

</body>

</html>
112 changes: 112 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

html,
body {
height: 100%;
font-family: Arial, sans-serif;
color: darkslategray;
}

body {
display: flex;
flex-direction: column;
font-size: 16px;
}

header {
background-color: darksalmon;
border-bottom: 1px solid gray;
padding: 1.5rem;
text-align: center;
}

header h1 {
color: brown;
margin: 0;
}

main {
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
background-color: lavender;
}

section {
display: flex;
padding: 1.5rem;
background-color: #f9f9f9;
overflow-y: auto;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
}

.section {
margin: 24px auto;
max-width: 400px;
display: flex;
flex-direction: column;
}

.section-content{
display: grid;
grid-template-columns: 1fr 1fr;
margin-bottom: 1rem;
gap: 2rem;
}

.smile-content {
text-align: center;
}

.sum-title{
color: chocolate;
font-size: 1.5rem;
margin-bottom: 2rem;
}

span{
color: chocolate;
font-size: 1.5rem;
}

button {
background-color: blueviolet;
color: bisque;
border: none;
padding: 0.7rem 1.5rem;
border-radius: 5px;
font-size: 1rem;
cursor: pointer;
margin: 1rem;
max-width: fit-content;
align-self: center;
}

label {
display: block;
margin-bottom: 0.7rem;
font-weight: 600;
}

input {
width: 100%;
padding: 0.8rem 1rem;
border: 1px solid gray;
border-radius: 5px;
font-family: inherit;
font-size: 1rem;
}

input:focus {
outline: none;
border-color: blueviolet;
box-shadow: 0 0 5px rgba(138, 43, 226, 0.5);
}