【发布时间】:2018-01-23 18:59:26
【问题描述】:
我正在与纸牌游戏进行简单匹配,我对按钮进行了一些样式设置以使其更具吸引力,但样式代码使其文本位于按钮之外,如果我移动文本,则按钮会随之移动如果有人能告诉我我在这里做错了什么,请这样做。
完整的 HTML 代码
<!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>
完整的 CSS 代码
.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;
}
*/
【问题讨论】: