how to align radios inputs in bootstrap?

Asked

Viewed 790 times

6

http://jsfiddle.net/96ra0n8h/

I did it this way:

<div class="row">

        <div class="col-md-2"> <p>Discordo Totalmente</p>  <p><input type="radio"/></p></div>
        <div class="col-md-2"> <p>Discordo</p> <p><input type="radio"/></p></div>
        <div class="col-md-2"> <p>Não Concordo nem discordo</p> <p><input type="radio"/></p></div>
        <div class="col-md-2"> <p>Concordo</p> <p><input type="radio"/></p></div>
        <div class="col-md-2"> <p>Concordo Totalmente</p> <p><input type="radio"/></p></div>
        <div class="col-md-2"> <p> (Não Aplicável)</p> <p><input type="radio"/></p></div>

</div>

Problem: When the screen is the size of the desktop, the text is not aligned with the radios.

I want the same effect as table:

<tr>
    <td>Muito d</td>
    <td>s</td>
    <td>Nem snem d</td>
    <td>sd</td>
    <td>Muito sd</td>
    <td>asd</td>
</tr>
<tr>
    <td>1 <input type="radio"  /></td>
    <td>2 <input type="radio"  /></td>
    <td>3 <input type="radio"  /></td>
    <td>4 <input type="radio" /></td>
    <td>5 <input type="radio"/> </td>
    <td>0 <input type="radio" /></td>
</tr>

text and input is misaligned

http://i.imgur.com/qBf90WP.png

I’d like to keep it lined up like this: http://i.imgur.com/qBf90WP.png

  • The two images are the same...

1 answer

5


I edited your code, see if it applies to your need:

http://jsfiddle.net/96ra0n8h/2/

I updated the code above. Note media query I created for devices or screens above 768px.

This CSS code can put on bootstrap.css that you have there or create another file .css... you know.

CSS

@media screen and (min-width: 768px){
    .p-1{
        height: 50px; 
        vertical-align:top;
    }
    .p-2{
        vertical-align: bottom; 
        line-height: 50px;
    }
}

<div class="col-sm-2">
    <p class="p-1">Discordo Totalmente</p>
    <p class="p-2"><input type="radio"></p>
</div>
<div class="col-sm-2">
    <p class="p-1">Discordo</p>
    <p class="p-2"><input type="radio"></p>
</div>
<div class="col-sm-2">
    <p class="p-1">Não Concordo nem discordo</p>
    <p class="p-2"><input type="radio"></p>
</div>
<div class="col-sm-2">
    <p class="p-1">Concordo</p>
    <p class="p-2"><input type="radio"></p>
</div>
<div class="col-sm-2">
    <p class="p-1">Concordo Totalmente</p>
    <p class="p-2"><input type="radio"></p>
</div>
<div class="col-sm-2">
    <p class="p-1">(Não Aplicável)</p>
    <p class="p-2"><input type="radio"></p>
</div>
  • 1

    worked, but the problem is when the screen is in mobile mode: everything that is text is above and all radios are below, IE, were separated.

  • That’s what I thought would happen, I explained in the post. But I’ll try to see another alternative.

  • 1

    You can elaborate another mobile marking for type one list and hide this from radios. But I’m not gonna do it, stay with Diego. :P

  • 1

    Ah can do... 17 hours I’m leaking fi... @Kaduamaral

  • 1

    kkkk I have other things to do, very boring by the way, I’m just taking some time here to cool off. rsrs

  • Okay, I made: http://jsfiddle.net/96ra0n8h/2/

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.