Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

twitter bootstrap 3 input-group-addon with btn-group not the same size

I have to make an input-group-btn in twitter bootstrap with a dropdown-menu attached to it but the output image below shows that the btn-group is not of the same size with the input group.

enter image description here

Here is the html code:

<div class="row">
<div class="col-md-2"><button type="button" class="btn btn-primary" onclick="showModalAddStation();">Add Station</button></div>
<div class="col-md-4">
     <div class="form-group">
        <div class="input-group">
        <div class="input-group-btn" >
            <div class="btn-group"> 
                <button class="btn btn-default btn-sm dropdown-toggle" type="button" data-toggle="dropdown">
                    <span data-bind="label" id="searchLabel">Search By</span> <span class="caret"></span>
                </button> 
                <ul class="dropdown-menu" role="menu">
                    <li><a href="#">1</a></li>
                    <li><a href="#">2</a></li>
                    <li><a href="#">3</a></li>
                </ul>
            </div>
        </div>  
        <input type="search" name="searchBy" id="searchBy" class="form-control" />
        <span class="input-group-btn">
            <button id="filter" class="btn  btn-primary btn-block glyphicon glyphicon-plus" onclick="searchStationTable();"></button>
        </span>
        </div>
     </div>
</div>
like image 840
jorrin Avatar asked Aug 14 '14 01:08

jorrin


People also ask

How do I change the input-group width in Bootstrap?

To set the width of the input-group-text , just change the value of the flex of the input-group , for instance, as seen above 30% of the total width.

What is BTN group?

“Button Groups” in Bootstrap is a class of name “btn-group” which is used to create series of buttons in groups (without spaces) vertically or horizontally. This is the basic syntax of the button group class where each button has its own class of “btn”.

What is input-group prepend?

input-group class is a container to enhance an input by adding an icon, text or a button in front or behind the input field as a "help text". Use . input-group-prepend to add the help text in front of the input, and . input-group-append to add it behind the input.

How do I make a small text box in Bootstrap?

Use the . input-sm class to set small input field in Bootstrap.


1 Answers

Your problems are :

  1. The button of dropdown-menu you have btn-sm class, it will decrease size of button http://getbootstrap.com/components/#btn-dropdowns-sizing

    solution : remove btn-sm class

  2. You are using glyphicon on the button.

    solution : you can use span, i tag or else on button if using glyphicon http://getbootstrap.com/components/#glyphicons-how-to-use


<div class="row">
<div class="col-md-2"><button type="button" class="btn btn-primary" onclick="showModalAddStation();">Add Station</button></div>
<div class="col-md-4">
     <div class="form-group">
        <div class="input-group">
        <div class="input-group-btn" >
            <div class="btn-group"> 
                <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">
                    <span data-bind="label" id="searchLabel">Search By</span> <span class="caret"></span>
                </button> 
                <ul class="dropdown-menu" role="menu">
                    <li><a href="#">1</a></li>
                    <li><a href="#">2</a></li>
                    <li><a href="#">3</a></li>
                </ul>
            </div>
        </div>  
        <input type="search" name="searchBy" id="searchBy" class="form-control" />
        <span class="input-group-btn">
            <button id="filter" class="btn btn-primary btn-block" onclick="searchStationTable();">
                <span class="glyphicon glyphicon-plus"></span>
            </button>
        </span>
        </div>
     </div>
</div>
</div>

http://jsfiddle.net/1hm7thq5/

like image 171
rails_id Avatar answered Sep 26 '22 13:09

rails_id