I've been working on a simple card matching game and I decided to style the buttons to enhance their appearance. However, I'm facing an issue where the styling code has caused the text to appear outside of the button. Whenever I try to adjust the text, the button also moves. Could someone please help me identify what I'm doing wrong?
Here is the complete HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>cardgame</title>
</head>
<body>
<h1 id="result">2</h1>
<form class="cards">
<div id="cards1"></div>
<input id="cards1[1]" value="1" name="card1" type="radio">
<label for="cards1[1]">1</label>
<input id="cards1[2]" value="2" name="card1" type="radio">
<label for="cards1[2]">2</label>
<input id="cards1[3]" value="3" name="card1" type="radio">
<label for="cards1[3]">3</label>
</div>
<div id="cards2">
<input id="cards2[1]" value="1" name="card2" type="radio"><label for="cards2[1]"> </label>
<input id="cards2[2]" value="2" name="card2" type="radio"><label for="cards2[2]"> </label>
<input id="cards2[3]" value="3" name="card2" type="radio"><label for="cards2[3]"> </label>
</div>
<input type="submit">
</form>
<script src="script.js" charset="utf-8"></script>
</body>
</html>
Here is the complete CSS code:
.credit {
background: lightyellow;
}
body {background-color: floralwhite}
label {
position: relative;
left: -15px;
top: -3px;
font-size: 8pt;
opacity: .5;
}
input[type="radio"] {
display: none;
}
input[type="radio"] + label:before {
background-color: white;
border: 2px solid #ccc;
border-radius: 6px;
content: "";
display: inline-block;
font-size: 12px;
height: 80px;
width: 50px;
line-height: 16px;
margin: 6px 6px 0 0;
vertical-align: middle;
}
/*
input[type="radio"]:checked + label:before {
border: 2px solid red;
}
*/