tarek hassan
tarek hassan

Reputation: 802

Bootstrap Navigation extends to more than viewport width

I am working with Bootstrap and creating a Wordpress theme. When I uploaded the website I found the menu button extends to the right, this happens only on mobile.

This is my nav bar code:

 <header class="site-header">
        <!-- Navbar -->
        <nav class="navbar navbar-expand-lg fixed-top navbar-fixed-top navbar-dark  bg-transparent ">
            <div class="container">
                <a class="navbar-brand" href="#">
                    <img src="<?php  echo get_bloginfo('template_url') ?>/assets/img/logo.png" />
                </a>
                <button class="navbar-toggler text-white" type="button" data-toggle="collapse"
                    data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false"
                    aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon text-white"></span>
                </button>


                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <ul class="navbar-nav ml-auto">
                        <li class="nav-item active">
                            <a class="nav-link text-white" href="#hero">HOME <span class="sr-only">(current)</span></a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link text-white ml-0 ml-lg-5" href="#talents">CHALLENGE</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link text-white ml-0 ml-lg-5" href="#contact-us-section">CONTACT US</a>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>


    </header>

The website on mobile after uploading

Upvotes: 0

Views: 64

Answers (1)

Ahmad Tahhan
Ahmad Tahhan

Reputation: 125

The issue is not with the header code, it's with the section class why-us-wrapper, since you are using AOS animations, it's causing an overflow and expanding the whole screen based on it as the element is coming from the right of screen.

Fix: else you add add position: relative to the .why-us-wrapper, or add overflow:hidden. You can add both.

.why-us-wrapper {
    min-height: 50vh;
    width: 100%;
    overflow: hidden;
    position: relative;
}

Upvotes: 1

Related Questions