2

I have an HTML as follows :

<div class="row">
 <div class="col-lg-4">
  <label for="email">E-Mail ID:</label>
 </div>
 <div class="col-lg-8 input-group" style="width:50%">
  <input type="text" id="userEmail" class="form-control" name="email" required />
  <span class="input-group-addon">@gmail.com</span>
  <hr/>
 </div>
</div>

I would like to add static text inside the box on the right hand side.

Eg (@gmail.com, the way it is on the google sign up form check image). Help much appreciated!

enter image description here

Mukul Kant
  • 7,074
  • 5
  • 38
  • 53
TheLuminor
  • 1,411
  • 3
  • 19
  • 34

4 Answers4

5

Something like this ?

.input-group input {
  border-right: 0px solid transparent;
}

.input-group .input-group-addon {
  background-color: transparent;
  border-left: 0px solid transparent;
}
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet"/>
<div class="row">
    <div class="col-lg-4">
        <label for="email">E-Mail ID:</label>
    </div>
    <div class="col-lg-8 input-group" style="width:50%">
        <input type="text" id="userEmail" class="form-control" name="email" required>
        <span class="input-group-addon">@gmail.com</span>
    </div>
</div>
Joel Almeida
  • 7,939
  • 5
  • 25
  • 51
3

Move the span over the input and set the right padding of the input the size of the span: https://jsfiddle.net/d65wyzoj/1/

Lucian
  • 644
  • 3
  • 13
2

Try this

.new
{
  position: absolute;
  padding: 10px;
  right: 0px;
  line-height: 10px;
}



 <div class="form-group ">
    <label class="control-label">
      <code>.inner-addon.<i>right</i>-addon</code>
    </label>
    <div class="inner-addon right-addon">
      <span class="new">@gmail.com</span>
      <input type="text" class="form-control" placeholder="Search" />
    </div>
  </div>
Shrinivas Pai
  • 7,491
  • 4
  • 29
  • 56
1

This is the most Elegant Solution you can find.

http://jsfiddle.net/t9ySU/

<div class="input-container">
    <input type="text"/>
</div>

.input-container {
    position: relative;
    float: left;
}
.input-container:after {
    position: absolute;
    right: 0;
    top: 0;
    content: '@gmail.com';
}
anandharshan
  • 5,817
  • 4
  • 34
  • 33