Skip to content
Open
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
6 changes: 6 additions & 0 deletions dark-mode.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

.dark-mode {
background-color: black;
color: white;
}

14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculator</title>
<link href="dark-mode.css" rel="stylesheet" type="text/css" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@700&display=swap" rel="stylesheet">
<script src="script.js"></script>
Expand Down Expand Up @@ -31,7 +32,20 @@
<button>+</button>
<button>0</button>
<button>.</button>

<button class="span-two">=</button>
<br/>
<br/>
<label class="switch">
<input onclick="toggleDark()"type="checkbox">
<span class="slider round"></span>
</label>
</div>
<script>
function toggleDark() {
var element = document.body;
element.classList.toggle("dark-mode");
}
</script>
</body>
</html>
174 changes: 117 additions & 57 deletions styles.css
Original file line number Diff line number Diff line change
@@ -1,58 +1,118 @@
*, *::before , *::after {
box-sizing: border-box;
font-family: 'Nunito', sans-serif;
font-weight: normal;
}

body {
padding: 0;
margin: 0;
background: linear-gradient(to right, #FDC830, #F37335);
}

.calculator-grid {
display: grid;
justify-content: center;
align-content: center;
min-height: 100vh;
grid-template-columns: repeat(4, 75px);
grid-template-rows: minmax(90px, auto) repeat(5, 75px);
}

.calculator-grid > button {
cursor: pointer;
font-size: 1.5rem;
border: 1px solid white;
outline: none;
background-color: rgba(255, 255, 255, .75);
}

.calculator-grid > button:hover {
background-color: rgba(255, 255, 255, .90);
}

.span-two {
grid-column: span 2;
}

.output {
grid-column: 1 / -1;
background-color: rgba(0, 0, 0, .75);
display: flex;
align-items: flex-end;
justify-content: space-around;
flex-direction: column;
padding: 10px;
word-wrap: break-word;
word-break: break-all;
}

.output .previous-operand {
color: rgba(255, 255, 255, .75);
font-size: 1 rem;
}

.output .current-operand {
color: white;
font-size: 1.75rem;

.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}

.switch input {
opacity: 0;
width: 0;
height: 0;
}

.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}

.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}

input:checked + .slider {
background-color: #2196F3;
}

input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
border-radius: 34px;
}

.slider.round:before {
border-radius: 50%;
}
*, *::before , *::after {
box-sizing: border-box;
font-family: 'Nunito', sans-serif;
font-weight: normal;
}

body {
padding: 0;
margin: 0;
background: linear-gradient(to right, #FDC830, #F37335);
}

.calculator-grid {
display: grid;
justify-content: center;
align-content: center;
min-height: 100vh;
grid-template-columns: repeat(4, 75px);
grid-template-rows: minmax(90px, auto) repeat(5, 75px);
}

.calculator-grid > button {
cursor: pointer;
font-size: 1.5rem;
border: 1px solid white;
outline: none;
background-color: rgba(255, 255, 255, .75);
}

.calculator-grid > button:hover {
background-color: rgba(255, 255, 255, .90);
}

.span-two {
grid-column: span 2;
}

.output {
grid-column: 1 / -1;
background-color: rgba(0, 0, 0, .75);
display: flex;
align-items: flex-end;
justify-content: space-around;
flex-direction: column;
padding: 10px;
word-wrap: break-word;
word-break: break-all;
}

.output .previous-operand {
color: rgba(255, 255, 255, .75);
font-size: 1 rem;
}

.output .current-operand {
color: white;
font-size: 1.75rem;
}