当单选按钮位于标签右侧时,垂直对齐它们?

如何对齐单选按钮?我希望它们能够排列在彼此之上。

jsfiddle

HTML:

<form>

  <label for="male">Male</label>

  <input type="radio" id="male" name="gender" value="male">

  <br>

  <label for="female">Female</label>

  <input type="radio" id="female" name="gender" value="female">

  <br>

  <label for="other">Other</label>

  <input type="radio" id="other" name="gender" value="other">


</form> 


素胚勾勒不出你
浏览 115回答 1
1回答

qq_遁去的一_1

有多种方法可以做到这一点。方法一:label {&nbsp; display: inline-block;&nbsp; width: 80px;}<html><body><h2>Radio Buttons</h2><form>&nbsp; <label for="male">Male</label>&nbsp; <input type="radio" id="male" name="gender" value="male">&nbsp; <br>&nbsp; <label for="female">Female</label>&nbsp; <input type="radio" id="female" name="gender" value="female">&nbsp; <br>&nbsp; <label for="other">Other</label>&nbsp; <input type="radio" id="other" name="gender" value="other">&nbsp;&nbsp;</form>&nbsp;</body></html>方法二:div {&nbsp; display: flex;&nbsp; width: 90px;&nbsp; justify-content: space-between;}<html><body><h2>Radio Buttons</h2><form>&nbsp; <div>&nbsp; <label for="male">Male</label>&nbsp; <input type="radio" id="male" name="gender" value="male">&nbsp; </div>&nbsp; <br>&nbsp; <div>&nbsp; <label for="female">Female</label>&nbsp; <input type="radio" id="female" name="gender" value="female">&nbsp; </div>&nbsp; <br>&nbsp; <div>&nbsp; <label for="other">Other</label>&nbsp; <input type="radio" id="other" name="gender" value="other">&nbsp; </div></form>&nbsp;</body></html>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5