Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap navbar dropdown - geocomplete suggestions appearing behind form

Using bootstrap 3 I've put a search form inside a navbar dropdown link and I am trying to use the JQuery Geocomplete plugin (http://ubilabs.github.io/geocomplete/) to populate the address form input. However, the address suggestions are appearing behind the form...is there any way to fix this with CSS?

Screenshot

In the header:

<script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places"></script>

HTML code:

<header class="navbar navbar-green navbar-fixed-top navbar-green" role="banner">
    <div class="container">
        <div class="navbar-header">
            <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse"> <span class="sr-only">Toggle navigation</span>
 <span class="icon-bar"></span>

                <span
                class="icon-bar"></span> <span class="icon-bar"></span>

            </button>   <a href="index.php" class="navbar-brand">Brand</a>

        </div>
        <nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
            <ul class="nav navbar-nav">
                <li><a href="#"><i class="icon-map-marker"></i> Browse</a>
                </li>
            </ul>
            <ul class="nav navbar-nav">
                <li class="dropdown active"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-search"></i> Find <b class="caret"></b></a>

                    <ul
                    class="dropdown-menu search">
                        <form class="navbar-form navbar-left" role="search">
                            <div class="form-group">
                                <button type="button" class="btn btn-default navbar-btn" data-toggle="tooltip"
                                data-placement="right" title="Use your exact location">
                                    <li class="icon-screenshot"></li>
                                </button>
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control" placeholder="Address" name="address"
                                id="address">
                            </div>
                            <div class="form-group">
                                <select class="form-control">
                                    <option>1</option>
                                    <option>2</option>
                                    <option>3</option>
                                    <option>4</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <button type="submit" class="btn btn-green">Search</button>
                            </div>
                        </form>
            </ul>
            </li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li class="dropdown">   <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-user"></i> USER<b class="caret"></b></a>

                    <ul
                    class="dropdown-menu">
                        <li><a href="#"><i class="icon-pencil"></i> Profile</a>
                        </li>
                        <li><a href="#"><i class="icon-upload"></i> Submit</a>
                        </li>
                        <li class="divider"></li>
                        <li><a href="#"><i class="icon-signout"></i> Log out</a>
                        </li>
            </ul>
            </li>
            </ul>
        </nav>
    </div>
</header>

And at the end of the document I have:

<script src="assets/js/jquery.geocomplete.js"></script>

<script>
    $(function () {
        $("#address").geocomplete({
            componentRestrictions: {
                country: 'GB'
            }
        })
    });
</script>
like image 503
Matt Avatar asked Aug 31 '13 20:08

Matt


1 Answers

The Google auto complete wraps the results in a container with class pac-container this container has a z-index of 1000 (set by inline css). The dropdown menu has the same z-index by default. To solve this add a higher z-index to the .pac-container:

 .pac-container { z-index:2000 !important; }

References:

  • http://benkammerling.wordpress.com/2012/02/17/google-maps-places-autocomplete-styling-in-css/
  • How do you style the dropdown on Google Places Autocomplete API?
like image 184
Bass Jobsen Avatar answered Oct 05 '22 23:10

Bass Jobsen