Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force radio button and its label to be on same line

If you have multiple radio buttons, each with a label, what is the most simple way to force the button/label pair to always be on the same line, and force the next pair down to the next line?

Large screen:

 () Label 1    () Label 2    () Label 3

On a small screen, what I want is this:

() Label 1
() Label 2
() Label 3

But what I'm getting is something like this:

() Label 1 ()
Label 2 ()
Label 3
like image 988
Casey Crookston Avatar asked Jun 17 '15 18:06

Casey Crookston


People also ask

How do I keep a radio button on one line?

As a quick solution either you can apply colspan for your td or You can have both the radio button controls in same td so that the change due to long text wont affect the display of radiobutton.

How do you put a label next to a radio button?

To label a radio button, add a <label> element after the <input> element and insert a for attribute with the same value as the id of the associated <input> element. Then, write your label text in the <label> tag.

How do I align a radio button horizontally?

To make a horizontal radio button set, add the data-type="horizontal" to the fieldset . The framework will float the labels so they sit side-by-side on a line, hide the radio button icons and only round the left and right edges of the group.


1 Answers

Looks like you need to make some HTML changes as well as CSS changes, I'd guess.

Example:

label {
  display: inline-block;
}

@media screen and (max-width: 768px) {
  label {
    display: block;
  }
}
<label for="radio_1">
  <input type="radio" name="radio" id="radio_1" />
  Label 1
</label>
<label for="radio_2">
  <input type="radio" name="radio" id="radio_2" />
  Label 2
</label>
<label for="radio_3">
  <input type="radio" name="radio" id="radio_3" />
  Label 3
</label>
<label for="radio_4">
  <input type="radio" name="radio" id="radio_4" />
  Label 4
</label>
like image 58
Josh Burgess Avatar answered Sep 25 '22 06:09

Josh Burgess