基本上,我正在尝试使所有按钮像第一个问题一样垂直对齐。我不明白为什么我不能正确回答第二个问题。我尝试了其他事情,例如使用vertical-align:middle属性,但是我什么都无法工作
body {
margin: 0px;
background-image: linear-gradient(to top, #48c6ef 0%, #6f86d6 100%);
}
#wrapper {
padding-top: 0px;
text-align: center;
margin-top: -1%;
margin-left: 20%;
margin-right: 20%;
background-color: white;
clear: both;
}
#quiz {
padding-bottom: 10px;
}
#quiz li {
list-style-type: none;
}
.question {
padding-bottom: 10px;
vertical-align: middle;
}
<div id="wrapper">
<div id="quiz">
<form name="quiz" method="post" name="buttons" id="quiz" onsubmit="return false">
<li>
<div class="question">1. How many continents are there?</div>
</li>
<input id="answer" type="radio" name="group1" value="wrong"> 6<br>
<input id="answer" type="radio" name="group1" value="wrong"> 8<br>
<input id="answer" type="radio" name="group1" value="correct"> 7<br>
<input id="answer" type="radio" name="group1" value="wrong"> 5
<hr>
<li>
<div class="question">2. Where is France located?</div>
</li>
<input id="answer" type="radio" name="group2" value="correct">Europe<br>
<input id="answer" type="radio" name="group2" value="wrong">Asia<br>
<input id="answer" type="radio" name="group2" value="wrong">Antarctica<br>
<input id="answer" type="radio" name="group2" value="wrong">North America
<hr>
</form>
</div>
</div>
答案 0 :(得分:1)
您的代码是正确的,它们已经在中间对齐了,但是根据文本,您的css不能以正确的方式显示,因此请对文本使用lebels并对齐标签
答案 1 :(得分:0)
将text-align: left;
与display: inline-block;
一起使用可以解决您的问题
body {
margin: 0px;
background-image: linear-gradient(to top, #48c6ef 0%, #6f86d6 100%);
}
#wrapper {
padding-top: 0px;
text-align: center;
margin-top: -1%;
margin-left: 20%;
margin-right: 20%;
background-color: white;
clear: both;
}
#quiz {
padding-bottom: 10px;
}
#quiz li {
list-style-type: none;
}
.question {
padding-bottom: 10px;
vertical-align: middle;
}
.wrap {
text-align: left;
display: inline-block;
}
<div id="wrapper">
<div id="quiz">
<form name="quiz" method="post" name="buttons" id="quiz" onsubmit="return false">
<li>
<div class="question">1. How many continents are there?</div>
</li>
<input id="answer" type="radio" name="group1" value="wrong"> 6<br>
<input id="answer" type="radio" name="group1" value="wrong"> 8<br>
<input id="answer" type="radio" name="group1" value="correct"> 7<br>
<input id="answer" type="radio" name="group1" value="wrong"> 5
<hr>
<li>
<div class="question">2. Where is France located?</div>
</li>
<div class="wrap">
<input id="answer" type="radio" name="group2" value="correct">Europe<br>
<input id="answer" type="radio" name="group2" value="wrong">Asia<br>
<input id="answer" type="radio" name="group2" value="wrong">Antarctica<br>
<input id="answer" type="radio" name="group2" value="wrong">North America
</div>
<hr>
</form>
</div>
</div>