simon peter simon peter - 1 year ago 108
CSS Question

Putting image beside an input field using bootstrap

I will like to put an image beside and input field using bootstrap. i want my output to be like :`enter image description here

but with the below code i get
enter image description here

<div class="form-group row">
<label for="inputTitle" class="col-sm-2 col-form-label">Title</label>
<div class="col-sm-10">
<span class="glyphicon glyphicon-phone"></span>
<input type="title" class="form-control" id="inputTitle" >

Answer Source

The form-control class will make your input 100% wide, meaning it will flow onto the next line. Additionally, it will make it display as a block element.

If I were you, I would look at using input groups instead, this is a nice tidy way of achieving the same effect:

Also, you have given your text input a type of title which is not valid. It's likely just a text input.

<script src=""></script>
<link rel="stylesheet" href="">
<script src=""></script>

<div class="input-group">
  <span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-phone"></span></span>
  <input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download