Search code examples
cssformstwitter-bootstrapinline

Bootstrap select form-inline input-group breaks at 768px


I don't know why but I have a form-inline working well but it breaks line at 768px and there is a scrollbar appearing just before the break at around 780px. Example: http://jsfiddle.net/qrrhzjd0/

Why does it breaks at 768px and why is a there a scrollbar on the body appearing just before the break?

I gave a try without the bootstrap select and I get the same line break, so it's not because of bootstrap select.

$("#SelectTopic").selectpicker({
    style: "btn-search",
    header: "Theme",
});
$("#SelectTheme").on("change", function() {
    $(".btn").blur();
});
#DivSearchItems {
    background: #fffffe;
    min-height: 45px;
    text-align: center;
    line-height: 53px;
}

#DivSearchItemsContent {
    display: inline-block;
    text-align: left;
    width:800px;
}

.btn-search {
    background-color: #fffffe;
    color: #282522 !important;
    border: 1px solid #282522;
}

#DivSearchItemsContent input {
    color: #282522 !important;
    border-top: 1px solid #282522;
    border-bottom: 1px solid #282522;
    border-right: none important;
    border-left: none !important;
}

#DivSearchItemsContent .btn-go {
    color: #282522 !important;
    border: 1px solid #282522;
    background: #f2f2f2;
    width: 60px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>


          <form class="form-inline">
          <div class="input-group">
              <div class="input-group-btn" style="width:150px;">
                  <select id="SelectTopic" name="SelectColour" class="form-control" class="btn-search">
                      <option value="">Theme</option>
                      <option value="Animals">Animals</option>
                      <option value="Nature">Nature</option>
                      <option value="Cities">Cities</option>
                  </select>
              </div>
              <div class="input-group" style="margin-top:-3px;"><input id="InputSearchItems" type="text" class="form-control" name="snpid" placeholder="Butterfly,nature, trees, etc..." style="width:400px;"></div>
              <span class="input-group-btn">
                 <button class="btn btn-orange btn-go" type="submit">GO</button>
              </span>
          </div>
          </form>
    


Solution

  • At 800 px scroll bar appears due to #DivSearchItemsContent width is set to 800px.

    At 768px there are some media query rule which is not present for mobile devices.That's why the input group breaks.

    I am not sure about the 780px issue.When we fix the #DivSearchItemsContent's width as 100%,then the scrollbar issue is not there.

    And these are the CSS for fixing your styling problems

    span.input-group-btn{
        width: auto !important;
    }
    
    .form-inline .input-group .input-group{
        display: inline-table !important;
        vertical-align: middle !important;
    }
    
    
    #DivSearchItemsContent{
        width:100% !important;
    }