I’m doing this little “project” to practice what I’ve learned this far, but I’ve encountered one problem that no matter how much I search on the web, I just couldn’t find the solution.
As you can see, the second image is a little bigger than the first one, but as I said in the title, I just resized both of them.
CSS:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Poppins";
height: 100vh;
}
form {
display: grid;
place-items: center;
}
legend {
text-align: center;
font-weight: bold;
}
fieldset {
padding: 10px;
display: flex;
gap: 10px;
}
.input-wrapper {
display: flex;
border: 1px solid black;
border-radius: 10px;
}
.input-wrapper img {
width: 200px;
height: 200px;
object-fit: cover;
}
label {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
width: 100%;
height: 100%;
border-radius: 10px;
border: 3px solid transparent;
transition: 0.10s;
}
label:hover {
cursor: pointer;
}
input {
appearance: none;
}
label:has(> input[type="radio"]:checked) {
background-color: rgba(37, 171, 255, 0.099);
}
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,700&family=Poppins:wght@300&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<form>
<fieldset>
<legend>Account type</legend>
<div class="input-wrapper">
<label for="personla-account">
<img src="imgs/man.png">
<input type="radio" name="account-type" id="personla-account" checked>
Personal
</label>
</div>
<div class="input-wrapper">
<label for="business-account">
<img src="imgs/business.png">
<input type="radio" name="account-type" id="business-account">
Business
</label>
</div>
</fieldset>
</form>
</body>
</html>
What am I doing wrong here? Or what am I missing?