Vertically aligning text next to a radio button

后端 未结 10 1998
醉梦人生
醉梦人生 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:15

    Used to this

        input[type="radio"]{
        vertical-align:top;
        }
    p{
        font-size:10px;line-height: 18px;
    }
    

    Demo

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

    You may try something like;

    <p><input type="radio" id="oddsPref" name="oddsPref" value="decimal" /><span>Decimal</span></p>
    

    and give the span a margin top like;

    span{
        margin-top: 4px;
        position:absolute;
    }
    

    here is the fiddle http://jsfiddle.net/UnA6j/11/

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

    simple and short solution add below style:

    style="vertical-align: text-bottom;"
    
    0 讨论(0)
  • 2021-01-01 09:22

    You need to align the text to the left of radio button using float:left

    input[type="radio"]{
    float:left;
    }
    

    You may use label too for more responsive output.

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