capiono
capiono

Reputation: 2997

Increase width of seach textbox inside navbar-header

I have a search textbox in navbar-header, on collapse, the width of the textbox is fine. But in full screen, the textbox width is reduced. How can I increase the width in full screen mode?

I know there are a lot of questions, like this on SO and the web.

However, I have tried all the suggestions, none has helped me.

here is my code, can someone tell what I'm doing wrong? Thanks.

.navbar .navbar-form {
  padding: 0 15px;
  border: 0;
  -webkit-box-shadow: none;
  box-shadow: none;
}
.navbar-inverse {
  background: #465f62;
  border: none;
}
.navbar-inverse .navbar-brand {
  color: white;
  font-size: 40px;
}
.navbar-inverse .navbar-nav > li > a {
  color: white;
  font-size: 18px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<div class="navbar navbar-inverse navbar-fixed-top">
  <div class="container-fluid">
    <div class="navbar-header">
      <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#navbar-collapse-area">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Colony</a>
      <div class="col-sm-6 col-md-6 col-lg-8">
        <form class="navbar-form" role="search">
          <div class="form-group" style="display:inline;">
            <div class="input-group">
              <input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
              <span class="input-group-btn">
                                <button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
                            </span>
            </div>
          </div>
        </form>
      </div>
    </div>
    <div class="collapse navbar-collapse" id="navbar-collapse-area">
      <ul class="nav navbar-nav navbar-right">
        <li class="dropdown">
          <a href="#" id="nbAcctDD" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Hello Doe <span class="caret"></span></a>
          <ul class="dropdown-menu pull-right">
            <li class="dropdown"><a href="#">Log Out</a>
            </li>
          </ul>
        </li>
      </ul>
    </div>
  </div>
</div>

Upvotes: 1

Views: 434

Answers (1)

Todd Mark
Todd Mark

Reputation: 1885

JSBIN

Because bootstrap(BT) just use the default input width to achieve the navbar input. So if you want to redefine the width of input, maybe jquery is a better choice.

$(window).resize(function (){
  var width = $(window).width();
  $('input').width(width - 380);
})

the number 380 is from of the colony and Hello Doe width. After all, there is enough space to arrangement all elements.

Upvotes: 1

Related Questions