-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6867f0
commit 65d123b
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="stylesheet" href="style.css" /> | ||
<title>Document</title> | ||
</head> | ||
|
||
<body class="center" > | ||
<div> | ||
<div > | ||
<input type="checkbox" id="fast" ></input><label for="fast">Fast</label> | ||
</div> | ||
<div > | ||
<input type="checkbox" id="cheap"></input><label for="cheap">Cheap</label> | ||
</div> | ||
<div > | ||
<input type="checkbox" id="good"></input><label for="good">Good</label> | ||
</div> | ||
</div> | ||
|
||
|
||
|
||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const checkFast = document.getElementById("fast"); | ||
const checkCheap = document.getElementById("cheap"); | ||
const checkGood = document.getElementById("good"); | ||
let lastTouched; | ||
|
||
checkFast.addEventListener("change", function () { | ||
if (numChecked() > 2) { | ||
lastTouched.checked = false; | ||
} | ||
lastTouched = checkFast; | ||
}); | ||
|
||
checkCheap.addEventListener("change", function () { | ||
if (numChecked() > 2) { | ||
lastTouched.checked = false; | ||
} | ||
lastTouched = checkCheap; | ||
}); | ||
|
||
checkGood.addEventListener("change", function () { | ||
if (numChecked() > 2) { | ||
lastTouched.checked = false; | ||
} | ||
lastTouched = checkGood; | ||
}); | ||
|
||
function numChecked() { | ||
let res = 0; | ||
if (checkFast.checked) { | ||
res += 1; | ||
} | ||
if (checkCheap.checked) { | ||
res += 1; | ||
} | ||
if (checkGood.checked) { | ||
res += 1; | ||
} | ||
return res; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.center { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
flex-direction: column; | ||
height: 100vh; | ||
|
||
font-size: 2rem; | ||
} | ||
|
||
input { | ||
margin: 2rem; | ||
transform: translateY(-0.2rem) scale(2); | ||
} |