Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search form pull-left/pull-right on the navigation bar does not work right in Chrome

I am migrating from the Twitter Bootstrap version 2.3.2 to the latest version 3 RC 1. Now I meet one problem with the search buttons in the top navigation bar. HTML code is below:

<body>
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <a class="navbar-brand" href="#">Brand</a>
            <div class="nav-collapse collapse">
                <ul class="nav navbar-nav">
                    <li><a href="#">Nav Item 1</a></li>
                    <li class="active"><a href="#">Nav Item 2</a></li>
                    <li><a href="#">Nav Item 3</a></li>
                    <li><a href="#">Nav Item 4</a></li>
                </ul>

                <form class="navbar-form pull-right">
                    <div class="input-group">
                        <input type="search" class="form-control" placeholder="Search"/>
                        <span class="input-group-btn">
                            <button type="submit" class="btn btn-default">Search</button>
                        </span> 
                    </div>
                </form>
            </div>
        </div>
    </div>
</body>

The problem is, it works perfectly in Firefox, but in Chrome or IE 9 it makes the search box super long and thus moves this search box and button below the navigation bar.

I tried troubleshooting and found if I removed "pull-right" from the form, the search box and button will be moved above inline with the navigation items, but lost the effect that pull-right brought - it would occupy all line space on the right.

Moreover as debugging if i replaced the search form with

            <form class="navbar-form pull-right">
                <div class="input-group">
                    <input type="text" placeholder="Search">
                    <button type="submit" class="btn btn-default">Search</button>
                </div>
            </form>

Then it will simply work well; but it's not my purpose either.

Any issue with my code? Or is it a problem with the version 3 RC 1? Anyway to address it?

like image 430
Bryant Zheng Avatar asked Aug 05 '13 09:08

Bryant Zheng


1 Answers

You can add the col-sm-4 class to your <form> element.

This should keep them the correct width depending on the screen width.

Play with the column sizing (col-sm-**) until you get it the way you want it.

See this jsFiddle demo

like image 120
Schmalzy Avatar answered Sep 19 '22 02:09

Schmalzy