The Bootstrap collapsible menu isn't expanding all the way when clicked

I've hit a roadblock with a small issue that I can't seem to resolve.

As a newcomer to bootstrap, I was working on programming the header with navigation when I encountered a problem that has me stumped. I'm reaching out for some assistance from you all.

The issue is as follows: When I resize my window to the point where the menu collapses and the nice 3 bar icon appears, everything works smoothly. However, upon clicking the icon, the menu slides open to the last item, then jumps back up, only displaying a partial amount of menu items. Additionally, a scrollbar appears on the side for navigating through the menu.

Below is my navigation code & style:

<header>

    <!-- NAVBAR
    ===========================================-->

        <nav class="navbar-wrapper">

            <div class="navbar navbar-collapsed-sm navbar-fixed-top navbar-default" role="navigation">

                <div class="container" >

                    <div class="navbar-header">

                        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".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 class="navbar-brand" href="/">navbar<span>brand</span>.nl</a>

                    </div> <!-- navbar-header -->

                    <nav class="navbar-collapse navbar-header-collapse collapse">

                        <ul class="nav navbar-nav navbar-right ">
                            <li class="active"><a href="/">Home</a></li>
                            <li><a href="blog.html">Blog</a></li>
                            <li><a href="resources.html">Resources</a></li>
                            <li><a href="aboutus.html">About us</a></li>
                            <li><a href="contact.html">Contact</a></li>
                        </ul> <!-- nav -->

                    </nav> <!-- navbar collapse -->

                </div> <!-- container -->

            </div> <!-- navbar -->

        </nav> <!-- navbar-wrapper -->

    </header> <!-- header -->

Here is the css

.navbar-default .navbar-toggle {
    border-color: #FFF !important;
    -webkit-border-radius: 2px;
    -mox-border-radius: 2px;
    border-radius: 2px;
    border-width: 2px;
    width: 46px;
    height: 36px;
    background-color: transparent;
}

.navbar-default .navbar-toggle:hover,
 .navbar-default .navbar-toggle:focus{
    border-color: #f79123 !important;
    background-color: #f79123;
}

.navbar-default .navbar-toggle .icon-bar {
    background-color: #fff;
}

ul.nav {
    margin: 21px 0 0 0;
    height: 39px;
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
}

ul.nav li a {
    margin: 0 15px 0 15px;
    padding: 0;
    display: block;
    height: 28px;
    background: none;
}

ul.nav li a:hover {
    background: none;
}

ul.nav li:last-child a {
    margin-right: 9px;
}

ul.nav li.active > a {
    border-bottom : 3px solid #f79123;
    background: none !important;
}

Looking forward to your help!

-- EDIT --- Here is a screenshot illustrating the problem https://gyazo.com/29fb5cae04dc5e59fdff06d08d4cf574

-- SOLUTION -- After much searching and confusion, it turns out there was an unnecessary height declaration for the UL element in my CSS further down the document. This leftover code from earlier experiments was causing the collapsing menu issue.

Thanks to Shehary for pointing this out.

Appreciate all of your attempts to assist!

Answer №1

Take out the height attribute from this section

ul.nav {
    margin: 21px 0 0 0;
    height: 39px; <---Remove this
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
}

Change it to

ul.nav {
    margin: 21px 0 0 0;  
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
}

Code Example

Answer №2

It seems like you are trying to find a way to remove the scroll-bar that appears when resizing and expanding the navbar on smaller screens.

To achieve this, you will need to make changes in the CSS code as shown below:

.navbar-fixed-bottom .navbar-collapse, .navbar-fixed-top .navbar-collapse {
    max-height: inherit;
}

Check out the JSFIDDLE demo here

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Adjusting the size of an image in HTML according to its dimensions

While working on creating an online shopping mall page, I encountered an issue. A majority of the images uploaded to my database have varying sizes, so I needed to resize them all. However, when I resized them and set their heights to be the same, some of ...

What is the best way to incorporate the :after pseudo-element in JavaScript code

HTML: This is my current code snippet <div class="one"> Apple </div> I am looking to dynamically add the word "juice" using JavaScript with the .style property. Is there an equivalent of :: after in CSS, where I can set the content in JavaS ...

Is there a way to implement HTML code that can automatically hide text based on the scroll size, similar to

Check out your Gmail inbox, where you'll notice 3 main columns Includes the sender's information Contains "THE_EMAIL_SUBJECT - THE_EMAIL_BODY" Showcases the date the email was sent on I observed that when resizing the window in the Gmail web c ...

The PHP file uploader form is limiting uploads to a maximum of 16 files

The XML files are compact and well below the maximum upload limit, with my max_file_upload value in php.ini set to 30. Up to 16 files can be uploaded in any combination. Interestingly, the form doesn't actually "POST," but it does redirect to the next ...

deactivate the struts anchor link once the request is sent to the action

To prevent users from clicking the anchor link multiple times while a request is being processed on the server side, I need to disable the anchor tag after sending the action and wait for the response. Additionally, there is an onclick event in my anchor t ...

Approach to Using Bootstrap 4 with Intl-Tel-Input

I've been attempting to integrate intl-tel-input with bootstrap 4, but I'm facing an issue where the placeholder for the input is not showing up. I've tried various solutions found online, but none of them seem to work. Here's my HTML ...

Guide on positioning a div to float from bottom left to top right using CSS as the window screen size is reduced

I am wondering if it is possible to float the div using CSS in the following manner. My goal is to have CSS DIV 2 move under CSS DIV 1 to the right when the window size is reduced. Please refer to the screenshot below: On larger window sizes, three DIVs a ...

Placing a div above the navigation bar in jQuery Mobile to create multiple stacked footers

I am currently facing an issue with my website where I have a static nav bar at the bottom of each page, but I need to add another content div above it. When I try to position it as a footer, it ends up in the same spot as the nav bar. Absolute positioning ...

Adjust the width of a textarea dynamically as you type by detecting keyup events

Two text areas have the same text formatting. Their IDs are textareaA and textareaB. I've successfully added functionality to resize textareaA on keyup. How can I make textareaB resize its WIDTH while the user is typing in textareaA? Here's wha ...

Guide to changing the checkbox value using JavaScript

Describing the Parent Element: <span style="background: yellow; padding: 50px;" onClick="setCheckBox()"> <span> </span> <input type="checkbox" name="f01" value="100"> </span> ...

Step-by-step guide on building a footer with relatively positioned elements

Is there a way to create a footer that stays at the bottom of the screen but also expands from the top based on the position of a specific element? I want it to have a fixed bottom position while adjusting its top side as needed. How can I achieve this? ...

When a td element is clicked, the Textbox will also be clicked

Similar Question: Dealing with jQuery on() when clicking a div but not its child $(oTrPlanning).prev().children('td').each(function () { this.onclick = setCountClick; }); When a TD element is clicked, the function setCountClick() i ...

Access the HTML file through the Heroku Bash terminal

After deploying my Flask python application on Heroku, I encountered an issue with one line of my python code where I need to open an HTML file for some javascript to execute. While it works fine locally on my Mac, Heroku seems to have trouble recognizing ...

Can a JavaScript function spontaneously run without being called upon?

<a onclick="determineCountry(data)" class="installbtn">Install</a> My goal is to have the user redirected to one of three sites based on their location when they click the button above. However, there seems to be an issue with the script below ...

Scraping HTML data without <div> tags with Scrapy - how to do it?

After spending hours attempting to extract a specific data set for use with Scrapy in a web scraping project, here is the current python code: bedrooms_info = house_listing.css( '.search-results-listings-list__item-description__charact ...

Scrolling background for a nested Bootstrap modal

I am facing an issue with a modal that has a lengthy content and a button to open another modal. Once the inner modal is closed, the outer modal becomes unresponsive. It fails to scroll and instead, the background starts to scroll. While I have come acros ...

Information has been stored in the database after being updated in an

I have a field that can be edited and I want to save the changes to the database. Here is the relevant HTML code: <ng-container *ngIf="groupedVolumes"> <ng-container *ngFor="let model of groupKeys() | slice:-3" > ...

Ensure that two cells within the same row of two tables are equal in width

I have 2 tables in the same row of a large table, set up like this: <table> <tr> <td>Type</td> <td>Storage 1</td> <td>Storage 2</td> </tr> ...

Display text below image in a reduced size for "mobile" screen

I am encountering an issue with my website where the font overlaps the image when viewed on a smaller device. How can I adjust the HTML or CSS to ensure that the text appears below the image on mobile devices? Below is the snippet of my HTML and CSS code: ...

Prevent page scrolling when an AngularJS dropdown is active

When using the angularjs dropdown, I encounter an issue where scrolling to the end of each side of the content triggers scrolling of the body, which can be quite bothersome. Is there a way to prevent the body document from scrolling when the dropdown is di ...