简体   繁体   中英

Bootstrap 3 Navbar Mobile Issue

I am having trouble getting bootstrap 3's navabar to be responsive on a mobile device. The navbar continues to span further than the mobile display, and I cannot figure out what I did wrong.

The Code: (HTML)

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">

         <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigationbar">
                    <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 img-responsive" href="index.html">
                    <img src="img/logo.png" width="320" height="85" alt="">
                </a>
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="navigationbar">
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <a href="index.html">Home</a>
                    </li>
                    <li>
                        <a href="index.html">Getting Started</a>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Products <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li>
                                <a href="products.html">Brain Seed™</a>
                            </li>
                        </ul>
                    </li>
                    <li>
                        <a href="about.html">About Us</a>
                    </li>
                    <li>
                        <a href="faq.html">FAQ</a>
                    </li>
                    <li>
                        <a href="contact.html">Contact Us</a>
                    </li>
                    <li>
                        <a href="contact.html"><button type="button pull-right" class="btn btn-success">ORDER NOW</button></a>
                    </li>


                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>

The Code: (CSS)

.navbar-fixed-top .nav {
    padding: 20px 0;
}

.navbar-fixed-top .navbar-brand {
    padding: 0 15px;
}

.page-content {
    padding-top: 40px;
}

.img-center {
    display: block;
    margin: 0 auto;
}

.navbar .brand { 
    max-height: 40px;
    max-width: 30%; 
    overflow: visible;
    padding-top: 0;
    padding-bottom: 0; 
}

I notice you in your html code, you typed fixed height and width, which cancels the img-responsive class. Start by removing that and go from there... enter link description here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM