Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the width of an .input-group in Bootstrap, responsively?

How do I change the width of an .input-group to make it wider? I tried setting width: 50% but that puts a space between the input field and the button.

bootstrap

new-width

I also tried setting the width of the input field directly, but that also failed.

bootstrap input 50%

And setting it over 100%, which also failed.

bootstrap input 110%

It looks good if I set the width to 300px or 400px, but not on mobile.

Here is a Bootply http://www.bootply.com/HGr9b06Q1B

like image 769
Chloe Avatar asked Apr 10 '15 19:04

Chloe


1 Answers

You need to wrap it in bootstraps structure... like:

<div class="container">
  <div class="row">
    <div class="col-sm-4 col-sm-offset-4"><!--width is set by this div -->

      <div class="input-group">
        <input type="text" class="form-control" placeholder="Search for...">
        <span class="input-group-btn">
          <button class="btn btn-default" type="button"><span class="glyphicon glyphicon-search"></span></button>
        </span>
      </div><!-- /input-group -->

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

See this fork of your bootply

Oh, and try not to use the <center> element, it has been deprecated.

like image 133
Ted Avatar answered Nov 15 '22 04:11

Ted