简体   繁体   English

单选按钮与文本对齐

[英]radio button align with text

I am trying to get my gender button to align with my radio image buttons this is the codes have so far.我试图让我的性别按钮与我的单选图像按钮对齐,这是迄今为止的代码。 It gives me the text above the button.它给了我按钮上方的文本。 Thank you in advance先感谢您

 <div class="genderalign"> <p>Choose:</p> <input type="radio" name="option" value="1" id="choose-1" /> <label for="choose-1"> <img src="/images/femaleC.png" /> </label> <input type="radio" name="option" value="2" id="choose-2" /> <label for="choose-2"> <img src="/images/maleC.png" /> </label> </div>

I've corrected the misplaced </div> so your HTML is now like this.我已经更正了错位的</div>因此您的 HTML 现在是这样的。

Then just apply flexbox然后只需应用 flexbox

 .genderalign { display: flex; align-items: center; }
 <div> <div class="genderalign"> <p>Choose:</p> <input type="radio" name="option" value="1" id="choose-1" /> <label for="choose-1"> <img src="/images/femaleC.png"/> </label> <input type="radio" name="option" value="2" id="choose-2" /> <label for="choose-2"> <img src="/images/maleC.png" /> </label> </div> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM