html
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
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div class="calculator">
<div class="result"></div>
<button class="delete">AC</button>
<button class="button">9</button>
<button class="button">*</button>
<button class="button">/</button>
<button class="button">8</button>
<button class="button">7</button>
<button class="button">6</button>
<button class="button">+</button>
<button class="button">5</button>
<button class="button">4</button>
<button class="button">3</button>
<button class="button">-</button>
<button class="button">2</button>
<button class="button">1</button>
<button class="button zero">0</button>
<button class="equal">=</button>
</div>
<script>
// all element a needed
const allButton = document.querySelectorAll('.button');
Enter to Rename, Shift+Enter to Preview
css
css
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
*,
*::before,
*::after
{
padding: 0;
margin: 0;
}
.calculator
{
min-height: 100vh;
width: 100vw;
display: grid;
grid-template-column: repeat(4, 1fr);
grid-template-row: 1fr 1fr 1fr 1fr 1fr;
grid-gap: 0.3rem;
}
.result
{
grid-column: 1/5;
grid-row: 1/4;
font-size: 2rem;
margin-left: 1rem;
}
.button
{
Enter to Rename, Shift+Enter to Preview
js
js
1
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run