Html 我的CSS替换按钮外的文本
我正在做一个简单的纸牌游戏,我设计了一些按钮,使其更具吸引力,但样式代码使其成为文本在按钮之外,如果我移动文本,按钮将随之移动,如果有人能告诉我我做错了什么,请做 完整的HTML代码Html 我的CSS替换按钮外的文本,html,css,button,text,Html,Css,Button,Text,我正在做一个简单的纸牌游戏,我设计了一些按钮,使其更具吸引力,但样式代码使其成为文本在按钮之外,如果我移动文本,按钮将随之移动,如果有人能告诉我我做错了什么,请做 完整的HTML代码 <!DOCTYPE html> <html lang="en"> <head> <link href="style.css" rel="stylesheet" type="text/css"> <meta charset="UTF-8"&
<!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>
将文本放在跨距内,然后尝试移动它。例如:
<div id="cards1">
<input id="cards1[1]" value="1" name="card1" type="radio">
<label for="cards1[1]"><span class="text">1</span></label>
<input id="cards1[2]" value="2" name="card1" type="radio">
<label for="cards1[2]"><span class="text">2</span></label>
<input id="cards1[3]" value="3" name="card1" type="radio">
<label for="cards1[3]"><span class="text">3</span></label>
</div>
将文本放在跨距内,然后尝试移动它。例如:
<div id="cards1">
<input id="cards1[1]" value="1" name="card1" type="radio">
<label for="cards1[1]"><span class="text">1</span></label>
<input id="cards1[2]" value="2" name="card1" type="radio">
<label for="cards1[2]"><span class="text">2</span></label>
<input id="cards1[3]" value="3" name="card1" type="radio">
<label for="cards1[3]"><span class="text">3</span></label>
</div>
要解决这个问题,您应该将输入的类型更改为按钮,然后将css更改为使用按钮,并在按钮周围添加一个用于卡的div,我已经解决了这个问题 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 class="card">
<input id="cards1[1]" value="1" name="card1" type="button">
</div>
<div class="card">
<input id="cards1[2]" value="2" name="card1" type="button">
</div>
<div class="card">
<input id="cards1[3]" value="3" name="card1" type="button">
</div>
</div>
<div id="cards2">
<input id="cards2[1]" value="1" name="card2" type="button"><label for="cards2[1]"> </label>
<input id="cards2[2]" value="2" name="card2" type="button"><label for="cards2[2]"> </label>
<input id="cards2[3]" value="3" name="card2" type="button"><label for="cards2[3]"> </label>
</div>
<input type="submit">
</form>
<script src="script.js" charset="utf-8"></script>
</body>
</html>
.credit {
background: lightyellow;
}
body {background-color: floralwhite}
label {
position: relative;
left: -15px;
top: -3px;
font-size: 8pt;
opacity: .5;
text-align: center
}
input[type="radio"] {
display: none;
}
input[type="button"] {
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;
}
.card {
position: relative;
display: inline;
}
要解决这个问题,您应该将输入的类型更改为按钮,然后将css更改为使用按钮,并在按钮周围添加一个用于卡的div,我已经解决了这个问题 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 class="card">
<input id="cards1[1]" value="1" name="card1" type="button">
</div>
<div class="card">
<input id="cards1[2]" value="2" name="card1" type="button">
</div>
<div class="card">
<input id="cards1[3]" value="3" name="card1" type="button">
</div>
</div>
<div id="cards2">
<input id="cards2[1]" value="1" name="card2" type="button"><label for="cards2[1]"> </label>
<input id="cards2[2]" value="2" name="card2" type="button"><label for="cards2[2]"> </label>
<input id="cards2[3]" value="3" name="card2" type="button"><label for="cards2[3]"> </label>
</div>
<input type="submit">
</form>
<script src="script.js" charset="utf-8"></script>
</body>
</html>
.credit {
background: lightyellow;
}
body {background-color: floralwhite}
label {
position: relative;
left: -15px;
top: -3px;
font-size: 8pt;
opacity: .5;
text-align: center
}
input[type="radio"] {
display: none;
}
input[type="button"] {
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;
}
.card {
position: relative;
display: inline;
}
这修复了我的代码,非常感谢。我还了解了标签,这是一个好消息。修复了我的代码,非常感谢。我还了解了标签,所以这是一个奖励