简体   繁体   English

中心对齐时如何使单选按钮平齐?

[英]How to make radio buttons flush when center aligned?

I have some radio buttons that I need center aligned, which they are. 我有一些单选按钮,它们需要居中对齐。 The only problem is that the buttons now aren't uniform on the left-hand side. 唯一的问题是按钮现在在左侧并不统一。 See image below: 见下图:

在此处输入图片说明

How would I go about keeping these centered but making them align flush? 我将如何保持它们居中但使它们对齐对齐?

I'm using text-align: center; 我正在使用text-align: center; to center everything. 集中一切。

Here is my HTML: 这是我的HTML:

<div class="select clearfix">
  <div id="product-select" name="id">
    <input type="radio" value="273138236" name="product">
    black + walnut - $190.00
    <br>
    <input type="radio" value="277905554" name="product">
    brown + walnut - $190.00
    <br>
    <input type="radio" value="277905654" name="product">
    black + cherry - $190.00
    <br>
    <input type="radio" value="277905752" name="product">
    brown + cherry - $190.00
    <br>
  </div>
</div>

Wrap them in a div that has text-align: left . 将它们包装在具有text-align: left的div中。 You could use the #product-select div for this purpose. 为此,您可以使用#product-select div。 However, you'll most likely need to switch to a different technique for centering the div since text-align does not affect block-level elements. 但是,由于text-align不会影响块级元素,因此您很可能需要切换到另一种技术来使div居中。

And for usability's sake, use <label> elements so people don't have to click the tiny radio button itself. 并且出于可用性的考虑,使用<label>元素,这样人们就不必单击微小的单选按钮本身。

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

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