skip to Main Content

I am using bootstrap in an attempt to create a form. Part of the form involves inputting social media links (FB, Linkedin & Twitter). I would like all of these inputs to be within one row – how can I do this? Thanks in advance.

http://jsfiddle.net/qn4mxqrq/1/

<HTML> 
<div class="form-group col-xs-12 col-sm-6 col-md-6 col-lg-2" id="upload_photo">

  <input type="image" src="img/square_face.png" alt="Submit" >

  <br> 
  <br>

</div>

<div class="form-group col-xs-12 col-sm-6 col-md-6 col-lg-6" id="upload_basic_info">

  <div class="form-group">
    <label for="firstname">Name</label>
    <input  type="text" class="form-control input" maxlength="50" data-error="Please fill out this field." name="name" id="name" placeholder="Name" required>
    <div class="help-block with-errors"></div>
  </div>

  <div class="form-group">
    <label for="lastname">Their Email Address </label>
    <input  type="text" class="form-control input" maxlength="50" data-error="Please fill out this field." name="email" id="email" placeholder="Their Email Address" required>
    <div class="help-block with-errors"></div>
  </div>

  <div class="form-group">
    <label for="country">Their Country</label>
    <select class="form-control input" data-error="Please fill out this field." name="country" id="country" required onchange="App.populate_option('Get_States', 'state', true, true, 'Create', $(this).val());">
      <option value="" disabled selected="selected">Their Country</option>
           </select>
    <div class="help-block with-errors"></div>
  </div>

  <div class="form-group">
    <label for="country">Their State/Region</label>
    <select class="form-control input" data-error="Please fill out this field." name="state" id="state" required disabled="disabled">
      <option value="" disabled selected="selected">Their State/Region</option>
    </select>
    <div class="help-block with-errors"></div>
  </div>


</div>

<div class="form-group col-xs-12" id="upload_socialmedia"><!--Start Social Media inputs -->

  <div class="form-group"><!--Start Facebook Input -->
    <label class="col-lg-2 control-label" name="facebook"></label>
    <div class="col-lg-10">
      <input id="upload_fb" name="facebook" id="facebook" placeholder="Facebook URL" type="url">
    </div>
  </div><!--End Facebook Input -->

  <div class="form-group"><!--Start Linkedin Input -->
    <label class="col-lg-2 control-label" name="linkedin"></label>
    <div class="col-lg-10">
      <input id="upload_linkedin" name="linkedin" id="linkedin" placeholder="Linkedin URL" type="url">
    </div>
  </div><!--End Linkedin Input -->

  <div class="form-group"><!--Start Twitter Input -->
    <label class="col-lg-2 control-label" name="twitter"><img src=></label>
    <div class="col-lg-10">
      <input id="upload_twitter" name="twitter" id="twitter" placeholder="Twitter URL" type="url">
      </div>
  </div><!--End Twitter Input -->

</div>  <!--End Social Media inputs -->

<CSS>
.container_upload{
width:1000px;
margin-left:60px;

}

#upload_photo{
height:150px;
width:300px;
}

.help-block {
display: block;
margin-top: 5px;
margin-bottom: 10px;
color: #737373
}

#upload_basic_info{
height:275px;
}

#upload_fb{
background: url(img/fb.png) no-repeat scroll 7px 7px;
padding-left:30px;
}
</CSS>

5

Answers


  1. I found a workaround, you can actually do it like this:

    <div class="form-group col-xs-12" id="upload_socialmedia"><!--Start Social Media inputs -->
          <!-- EDIT THIS CLASS (and the two others) -->
          <div class="form-group col-xs-4"><!--Start Facebook Input -->
            <label class="col-lg-2 control-label" name="facebook"></label>
            <div class="col-lg-10">
              <input id="upload_fb" name="facebook" id="facebook" placeholder="Facebook URL" type="url">
            </div>
          </div><!--End Facebook Input -->
    
          <div class="form-group col-xs-4"><!--Start Linkedin Input -->
            <label class="col-lg-2 control-label" name="linkedin"></label>
            <div class="col-lg-10">
              <input id="upload_linkedin" name="linkedin" id="linkedin" placeholder="Linkedin URL" type="url">
            </div>
          </div><!--End Linkedin Input -->
    
          <div class="form-group col-xs-4"><!--Start Twitter Input -->
            <label class="col-lg-2 control-label" name="twitter"><img src=""></label>
            <div class="col-lg-10">
              <input id="upload_twitter" name="twitter" id="twitter" placeholder="Twitter URL" type="url">
              </div>
          </div><!--End Twitter Input -->
    
        </div>  <!--End Social Media inputs -->
    

    EDIT: Sorry, it looks like I missread the original problem. So @Manuel Choucino’s answer seems to be the good one.

    Login or Signup to reply.
  2. Just use left floats.

    .class{float:left;}
    

    If I have understood what you want correctly:

    http://jsfiddle.net/qn4mxqrq/4/

    This is an edited version of your code.

    Login or Signup to reply.
  3. When I look at your code, there is one Class name that control all of group. form-group.

    in your CSS just create rules for that socialForm.

    .socialForm{
      float: left;
    }
    
    Login or Signup to reply.
  4. You can simply place those three inputs in an single row and apply col-*-4 to each.

    See working example Snippet.

    body {
      padding-top: 50px;
    }
    #upload_culprit_photo {
      margin-bottom: 20px;
    }
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
    <div class="container">
      <div class="row">
        <div class="col-xs-12 col-sm-6">
          <input type="image" src="http://placehold.it/300x150" class="img-responsive center-block" id="upload_culprit_photo" />
        </div>
        <div class="col-xs-12 col-sm-6" id="upload_basic_info">
          <div class="form-group">
            <label for="firstname">Name</label>
            <input type="text" class="form-control" maxlength="50" data-error="Please fill out this field." name="name" id="name" placeholder="Name" required>
            <div class="help-block with-errors"></div>
          </div>
    
          <div class="form-group">
            <label for="lastname">Their Email Address</label>
            <input type="text" class="form-control" maxlength="50" data-error="Please fill out this field." name="email" id="email" placeholder="Their Email Address" required>
            <div class="help-block with-errors"></div>
          </div>
    
          <div class="form-group">
            <label for="country">Their Country</label>
            <select class="form-control" data-error="Please fill out this field." name="country" id="country" required onchange="App.populate_option('Get_States', 'state', true, true, 'Create', $(this).val());">
              <option value="" disabled selected="selected">Their Country</option>
            </select>
            <div class="help-block with-errors"></div>
          </div>
          <div class="form-group">
            <label for="country">Their State/Region</label>
            <select class="form-control" data-error="Please fill out this field." name="state" id="state" required disabled="disabled">
              <option value="" disabled selected="selected">Their State/Region</option>
            </select>
            <div class="help-block with-errors"></div>
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-sm-4">
          <div class="form-group">
            <label name="facebook">Facebook</label>
            <input id="upload_fb" class="form-control" name="facebook" id="facebook" placeholder="Facebook URL" type="url">
          </div>
        </div>
        <div class="col-sm-4">
          <div class="form-group">
            <label name="linkedin">LinkedIn</label>
            <input id="upload_linkedin" class="form-control" name="linkedin" id="linkedin" placeholder="Linkedin URL" type="url">
          </div>
        </div>
        <div class="col-sm-4">
          <div class="form-group">
            <label name="twitter">Twitter</label>
            <input id="upload_twitter" class="form-control" name="twitter" id="twitter" placeholder="Twitter URL" type="url">
          </div>
        </div>
      </div>
    </div>
    Login or Signup to reply.
  5. Here adding bootstrap classes like col-lg,col-md,col-sm,col-xs every class will work different devices.example:col-lg its works in large size desktop(1920 *1080 resolution ),col-md works in medium size desktop(1366*768 resolution )
    ,col-sm works in tablets and col-xs works in mobiles

    Hope my answer will work in all devices.

    body {
      padding-top: 50px;
    }
    #upload_culprit_photo {
      margin-bottom: 20px;
    }
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
    <div class="container">
      <div class="row">
        <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 ">
          <input type="image" src="http://placehold.it/300x150" class="img-responsive center-block" id="upload_culprit_photo" />
        </div>
        <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 " id="upload_basic_info">
          <div class="form-group">
            <label for="firstname">Name</label>
            <input type="text" class="form-control" maxlength="50" data-error="Please fill out this field." name="name" id="name" placeholder="Name" required>
            <div class="help-block with-errors"></div>
          </div>
    
          <div class="form-group">
            <label for="lastname">Their Email Address</label>
            <input type="text" class="form-control" maxlength="50" data-error="Please fill out this field." name="email" id="email" placeholder="Their Email Address" required>
            <div class="help-block with-errors"></div>
          </div>
    
          <div class="form-group">
            <label for="country">Their Country</label>
            <select class="form-control" data-error="Please fill out this field." name="country" id="country" required onchange="App.populate_option('Get_States', 'state', true, true, 'Create', $(this).val());">
              <option value="" disabled selected="selected">Their Country</option>
            </select>
            <div class="help-block with-errors"></div>
          </div>
          <div class="form-group">
            <label for="country">Their State/Region</label>
            <select class="form-control" data-error="Please fill out this field." name="state" id="state" required disabled="disabled">
              <option value="" disabled selected="selected">Their State/Region</option>
            </select>
            <div class="help-block with-errors"></div>
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
          <div class="form-group">
            <label name="facebook">Facebook</label>
            <input id="upload_fb" class="form-control" name="facebook" id="facebook" placeholder="Facebook URL" type="url">
          </div>
        </div>
        <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
          <div class="form-group">
            <label name="linkedin">LinkedIn</label>
            <input id="upload_linkedin" class="form-control" name="linkedin" id="linkedin" placeholder="Linkedin URL" type="url">
          </div>
        </div>
        <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
          <div class="form-group">
            <label name="twitter">Twitter</label>
            <input id="upload_twitter" class="form-control" name="twitter" id="twitter" placeholder="Twitter URL" type="url">
          </div>
        </div>
      </div>
    </div>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search