Vertically aligning text next to a radio button

后端 未结 10 1997
醉梦人生
醉梦人生 2021-01-01 08:36

This is a basic CSS question, I have a radio button with a small text label after it. I want the text to appear centered vertically but the text is always aligned with the b

相关标签:
10条回答
  • 2021-01-01 09:03

    This will give dead on alignment

    input[type="radio"] {
      margin-top: 1px;
      vertical-align: top;
    }
    
    0 讨论(0)
  • 2021-01-01 09:07

    I think this is what you might be asking for

    http://jsbin.com/ixowuw/2/

    CSS

    label{
      font-size:18px;
      vertical-align: middle;
    }
    
    input[type="radio"]{
      vertical-align: middle;
    }
    

    HTML

    <span>
      <input type="radio" id="oddsPref" name="oddsPref" value="decimal" />
      <label>Decimal</label>
    </span>
    
    0 讨论(0)
  • 2021-01-01 09:07

    HTML:

    <label><input type="radio" id="opt1" name="opt1" value="1"> A label</label>
    

    CSS:

    label input[type="radio"] { vertical-align: text-bottom; }
    
    0 讨论(0)
  • 2021-01-01 09:08

    Use it inside a label. Use vertical-align to set it to various values -- bottom, baseline, middle etc.

    http://jsfiddle.net/UnA6j/5/

    0 讨论(0)
  • 2021-01-01 09:09

    You could also try something like this:

    input[type="radio"] {
      margin-top: -1px;
      vertical-align: middle;
    }
      <label  class="child"><input id = "warm" type="radio" name="weathertype" value="warm" checked> Warm<br></label>
    <label class="child1"><input id = "cold" type="radio" name="weathertype" value="cold" checked> Cold<br></label>

    0 讨论(0)
  • 2021-01-01 09:09

    input.radio {vertical-align:middle; margin-top:8px; margin-bottom:12px;}

    SIMPLY Adjust top and bottom as needed for PERFECT ALIGNMENT of radio button or checkbox

    <input type="radio" class="radio">

    0 讨论(0)
提交回复
热议问题