Skip to content Skip to sidebar Skip to footer

How To Position Elements Next To Each Other In A Div?

I am trying to position the elements next to each other. but the third field keeps appearing in a separate row. How can i position the two radio buttons and email field next to ea

Solution 1:

I think that using flexbox is a much better approach to organize elements like this. It's mostly supported, not buggy as floats and easy to use.

.disp {
  display: flex;
justify-content: space-evenly;
}
<div class="row disp">
  <label>
    <input name="select_source" id="select-source-radio-btn" type="radio"/>
    <span style="font-size: medium;font-weight: bold;  margin: 5px;">SELECT A SOURCE</span>
  </label>
  <label>
    <input name="select_source"  id="select-group-radio-btn" type="radio"/>
    <span style="font-size: medium ;font-weight: bold;">SELECT A GROUP</span>
  </label>
  <div class="input-field disp">
    <input id="email" type="email" class="validate" placeholder="Email">
  </div>
</div>

Solution 2:

You can add display block to both divs like this:

.disp {
  display:inline-block;
}
<div class="row disp">
  <label>
    <input name="select_source" id="select-source-radio-btn" type="radio"/>
    <span style="font-size: medium;font-weight: bold;  margin: 5px;">SELECT A SOURCE</span>
  </label>
  <label>
    <input name="select_source"  id="select-group-radio-btn" type="radio"/>
    <span style="font-size: medium ;font-weight: bold;">SELECT A GROUP</span>
  </label>
  <div class="input-field disp">
    <input id="email" type="email" class="validate" placeholder="Email">
  </div>
</div>

Solution 3:

you can do display:inline-block or float:left after the first div


Solution 4:

you can use css on the div if you want as well

    div {
      display:inline-block;
    }
    <div class="row">
  <label>
    <input name="select_source" id="select-source-radio-btn" type="radio"/>
    <span style="font-size: medium;font-weight: bold;  margin: 5px;">SELECT A     SOURCE</span>
  </label>
  <label>
    <input name="select_source"  id="select-group-radio-btn" type="radio"/>
    <span style="font-size: medium ;font-weight: bold;">SELECT A GROUP</span>
  </label>
  <div class="input-field">
    <input id="email" type="email" class="validate" placeholder="Email">
  </div>
</div>

Solution 5:

If you don't wanna do CSS for the same try doing:

<div class="row">
  <label>
    <input name="select_source" id="select-source-radio-btn" type="radio"/>
    <span style="font-size: medium;font-weight: bold;  margin: 5px;">SELECT A SOURCE</span>
  </label>
  <label>
    <input name="select_source"  id="select-group-radio-btn" type="radio"/>
    <span style="font-size: medium ;font-weight: bold;">SELECT A GROUP</span>
  </label>
  <span class="input-field">
    <input id="email" type="email" class="validate" placeholder="Email">
  </span>
</div>

You shall get the desired results


Post a Comment for "How To Position Elements Next To Each Other In A Div?"