Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap CSS for RadiobuttonList

Radion button :

   <div class="control-group">
    <label class="control-label">Mode</label>
    <div class="controls">
        <asp:radiobuttonlist id="RadioButtonList1" cssclass="radio" autopostback="true" title="Please Select Mode of Payment"
          repeatdirection="Horizontal"
          onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
            <asp:listitem>Cash</asp:listitem>
            <asp:listitem>Cheque</asp:listitem>
            <asp:listitem>Demand Draft</asp:listitem>
            <asp:listitem>Net Banking</asp:listitem>
        </asp:radiobuttonlist>
    </div>
   </div>

I have applied the Bootstrap css for:

  • text box,
  • dropdown list,
  • textarea,
  • buton, etc.

Everything looks fine, except for radiobutton list, which looks terrible:

enter image description here

How to solve this ?

like image 729
King_Fisher Avatar asked Dec 16 '14 07:12

King_Fisher


People also ask

What is the default layout of radio buttons in bootstrap?

By default, any number of checkboxes and radios that are immediate sibling will be vertically stacked and appropriately spaced with .form-check .


2 Answers

I could not use a <label> and <input type="radio">

So this is what I used:

<asp:RadioButtonList ID="popiRadios" RepeatLayout="Flow" RepeatDirection="Horizontal" runat="server">
                        <asp:ListItem class="radio-inline" Value="1" Text="Cash" Selected="True"></asp:ListItem>
                        <asp:ListItem class="radio-inline" Value="0" Text="Cheque"></asp:ListItem>
                    </asp:RadioButtonList>

And it came out like this:

enter image description here

like image 78
abiNerd Avatar answered Sep 24 '22 13:09

abiNerd


There are plenty of option you can choose, but i feel the best is in my experience is below.

  1. First set style in the top of your form as shown below

    <style>
        .radiostyle {
          height: auto;
        }
    
        .radiostyle label {
            margin-left: 3px !important;
            margin-right: 10px !important;
        }
    </style>
    
  2. Second you should apply the clss to the ASP.NET RadioButtonList control

like image 33
Abhilash Thomas Avatar answered Sep 24 '22 13:09

Abhilash Thomas