-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
156 lines (134 loc) · 5.19 KB
/
index.html
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Math Table Generator</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel="stylesheet" href="style.css">
</head>
<style>
.input-group {
position: relative;
margin-bottom: 20px;
}
.input-group__input {
font-size: 18px;
font: inherit;
color: black;
padding: 10px;
border: none;
border-radius: 4px;
outline: 2px solid black;
background-color: transparent;
transition: outline-color 500ms;
width: 100%;
}
.input-group__input:is(:focus, :valid) {
outline-color: black;
}
.input-group__label {
position: absolute;
top: 0;
left: 0;
padding: 8px;
color: black;
transition: transform 500ms, background-color 500ms;
transform-origin: top left;
background-color: transparent;
}
.input-group__label.active {
transform: translate(10px, -17px) scale(0.8);
background-color: white;
}
@media (max-width: 576px) {
.input-group__input {
font-size: 24px;
}
}
</style>
<body>
<header class="header">
<div class="top_bar">
<div class="container">
<div class="row">
<div class="col d-flex flex-row">
<div class="top_bar_contact_item"> <div class="top_bar_icon"><img src="https://res.cloudinary.com/dxfq3iotg/image/upload/v1560918577/phone.png" alt=""></div>+92 331 2269636</div>
<div class="top_bar_contact_item"><div class="top_bar_icon"><img src="https://res.cloudinary.com/dxfq3iotg/image/upload/v1560918597/mail.png" alt=""></div><a href="mailto:ahmedmujtaba03007098129@gmail.com">ahmedmujtaba03007098129@gmail.com</a></div>
<div class="top_bar_contact_item"> Made By<a href="https://www.github.com/ahmedmujtaba1" target="_blank">Ahmed Mujtaba</a></div>
<div class="top_bar_content ml-auto">
<div class="top_bar_menu">
</div>
</div>
</div>
</div>
</div>
</div>
</header>
<div class="container mt-5">
<div class="row">
<div class="col-md-6 offset-md-3">
<h2 class="text-center">Math Table Generator</h2>
<form id="mathForm">
<div class="input-group">
<input type="number" id="numberInput" class="input-group__input" required>
<label for="numberInput" class="input-group__label">Enter number</label>
</div>
<button type="submit" class="btn btn-primary">Generate Table</button>
</form>
</div>
</div>
<div class="row mt-5" id="resultTable">
<div class="col-md-6 offset-md-3">
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/js/all.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.1.3/TweenMax.min.js"></script>
<script>
const numberInput = document.getElementById('numberInput');
const label = document.querySelector('.input-group__label');
numberInput.addEventListener('focus', function () {
label.classList.add('active');
});
numberInput.addEventListener('blur', function () {
if (!numberInput.value.trim()) {
label.classList.remove('active');
}
});
document.getElementById('mathForm').addEventListener('submit', function (event) {
event.preventDefault();
generateMathTable();
});
function generateMathTable() {
const numberInputValue = parseInt(document.getElementById('numberInput').value);
const resultTable = document.getElementById('resultTable');
resultTable.innerHTML = '';
const table = document.createElement('table');
table.classList.add('table', 'table-bordered');
const headerRow = document.createElement('tr');
for (let num = numberInputValue; num <= 20; num++) {
const th = document.createElement('th');
th.textContent = `${num} Times Table`;
headerRow.appendChild(th);
}
table.appendChild(headerRow);
for (let no = 1; no <= 12; no++) {
const resultRow = document.createElement('tr');
for (let num = numberInputValue; num <= 20; num++) {
const resultCell = document.createElement('td');
const result = `${num} × ${no} = ${num * no}`;
resultCell.textContent = result;
resultRow.appendChild(resultCell);
}
table.appendChild(resultRow);
}
resultTable.appendChild(table);
}
</script>
</body>
</html>