Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increasing Bootstrap navbar search form width

This is only the second time I've used stackoverflow so please forgive me if I make any mistakes.

I'm having an issue increasing the width of the default Bootstrap navbar search form. I have tried some of the solutions I've seen on stackoverflow, however nothing seems to work.

Please see: http://jsfiddle.net/94zkLh8j/1/

<nav class="navbar navbar-inverse navbar-fixed-top">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" class="read-more" data-target="#bs-example-navbar-collapse-1">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#">Vouchipster</a>
                </div>
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <form class="navbar-form navbar-right" role="search">
                        <div class="form-group">
                            <div style="display:table;" class="input-group">
                                <input type="text" class="form-control" placeholder="Search for retailers, categories or products">
                                <span class="input-group-btn">
                                    <button class="btn btn-green" type="button"><i class="fa fa-search"></i></button>
                                </span>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </nav>
like image 960
user3383616 Avatar asked May 28 '15 15:05

user3383616


People also ask

How do I increase the size of the navbar search box?

Go to Customizer > Layout > Primary Navigation and increase the Menu Item Height as this sets the size of the logo.

How do I make my Bootstrap navbar wider?

In Bootstrap 4, full width dropdown in Navbar might be possible by adding CSS properties either internally or externally based on conveniences. Focus on class dropdown and dropdown-menu only. Now, make top margin of dropdown-menu as zero pixel and add width to 100%. We can also use CSS properties through inline method.

What does navbar expand Md do?

With Bootstrap, a navigation bar can extend or collapse, depending on the screen size. A standard navigation bar is created with the .navbar class, followed by a responsive collapsing class: .navbar-expand-xl|lg|md|sm (stacks the navbar vertically on extra large, large, medium or small screens).


1 Answers

You can set the width of the input element in your document stylesheet. Use !important to override any bootstrap widths. I recommend adding an id to the form for easy selection in css

Updated Fiddle

HTML

...
 <form class="navbar-form navbar-right" role="search" id="navBarSearchForm">
...

CSS

<style>
    #navBarSearchForm input[type=text]{width:430px !important;}
</style>
like image 150
Brino Avatar answered Oct 08 '22 19:10

Brino