-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask4.html
More file actions
62 lines (56 loc) · 1.79 KB
/
task4.html
File metadata and controls
62 lines (56 loc) · 1.79 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Розмір квадрата</title>
<style>
#square {
width: 30px;
height: 30px;
background-color: rgb(122, 185, 122);
margin-bottom: 20px;
border: 2px dashed rgb(201, 28, 28);
margin-left: 30px;
}
button {
padding: 10px 20px;
font-size: 16px;
margin-right: 10px;
}
</style>
</head>
<body>
<div style="background-color: rgb(122, 185, 122); width: 300px; height: 200px; text-align: center;">
<h2 style="color: rgb(226, 99, 99);">Завдання 4</h2>
<p>Результат:</p>
<div id="square"></div>
<button onclick="decreaseSize()">Зменшити</button>
<button onclick="increaseSize()">Збільшити</button>
</div>
<script>
var square = document.getElementById("square");
var currentSize = 30;
function decreaseSize() {
currentSize -= 15;
if (currentSize >= 15) {
square.style.width = currentSize + "px";
square.style.height = currentSize + "px";
} else {
alert("Квадрат вже мінімального розміру!");
currentSize += 15;
}
}
function increaseSize() {
currentSize += 15;
if (currentSize <= 45) {
square.style.width = currentSize + "px";
square.style.height = currentSize + "px";
} else {
alert("Квадрат досяг максимального розміру!");
currentSize -= 15;
}
}
</script>
</body>
</html>