简体   繁体   English

单选按钮和关联的 Label 未对齐

[英]Radio Button and associated Label not aligned

Radio buttons are showing like the attached image.单选按钮显示如附加图像。 How to align the Label and the button.如何对齐 Label 和按钮。

 input[type="radio"] { width: 18px; min-width: auto; display: inline-block; }
 <label><input type="radio" name="myRadios1" id="myRadios1" value="Yes" ONCLICK="show_info_block(this.value)" />Yes</label> <label><input type="radio" name="myRadios2" id="myRadios2" value="No" ONCLICK="show_info_block(this.value)" />No</label>

I have 2 solutions but i think one of them is better:我有 2 个解决方案,但我认为其中一个更好:

  1. first Dont wrap you <input> in <label> and do this instead:首先不要将<input>包裹在<label>中,而是这样做:

    {label} {标签}
  2. then for css:然后对于 css:

    .label-container { display: flex; .label-container { 显示:弹性; align-items: center;对齐项目:居中; } }

    input[type='radio'] { margin: auto;输入[类型='收音机'] {边距:自动; } }

you can use display flex and align-items: center for each label with your own code but I think it's not clean at all.您可以使用 display flex 和 align-items: center 为每个 label 使用您自己的代码,但我认为它根本不干净。

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

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