htmlcsstwitter-bootstraptwitter-bootstrap-3

Issue with bootstrap aligning textbox next to button


I'm trying to build what I have attached in the image but unfortunately I cannot get it to sit right, so far this is my HTML (I'm new to bootstrap)

<div class="row">
  <div class="container">
    <div class="col-lg-3">
    </div>
    <div class="col-lg-6">
        <p class="text-center">
            <strong>Enter your email and get special information</strong>
        </p>
        @using (Html.BeginForm("Index", "Home", FormMethod.Post, new { @class = "form-inline col-lg-12" }))
        {
            <div class="input-group col-lg-9" style="margin-left: 3%">
                <input type="text" class="form-control">
            </div>
            <div class="input-group col-lg-2">
                <button class="btn btn-primary">Submit</button>
            </div>
        }
    </div>
    <div class="col-lg-3">

    </div>
 </div>
</div>

which is meant to look like this

enter image description here

but instead looks like this, Ideally I would like the button in a bit closer to the text box

enter image description here

but when I view it on a mobile screen I get this mess

enter image description here

Any help would be appreciated.


Solution

  • What about this fiddle:

    http://jsfiddle.net/jwyr6Lwh/1/

        .custom input.form-control {
            border: 1px solid #848484; 
            -webkit-border-radius: 30px !important; 
            -moz-border-radius: 30px !important; 
            border-radius: 30px !important;
            -moz-box-shadow: 2px 2px 1px #666;
            -webkit-box-shadow: 2px 2px 1px #666;
            box-shadow: 2px 2px 1px #666;
            outline:0; 
            padding-left:10px; 
            padding-right:0px; 
            background-color: rgba(255,255,255,0.2);
    
        } 
    
        .custom  button {
            -webkit-border-radius: 20px;
            -moz-border-radius: 20px;
            border-radius: 20px;
        }
    

    The reason why it is displayed different on a mobile Browser is its responsiveness

    class="col-lg-2"
    

    means that on an large device it will be displayed in two columns otherwise one by one under the other. If you don't intend this take class="col-sg-2".

    enter image description here