Fixed Collapse of Vertical Navbar in Bootstrap 4

Currently delving into the world of bootstrap and facing a challenge.

I am attempting to craft a vertical navbar on the left side of the page once the user has scrolled past the full-page 'intro' element using bootstrap 4. The code snippet provided below accomplishes the positioning of the navbar on the left side, however, there seems to be an issue.

  • The navbar remains in a collapsed state even after resizing the window multiple times

What could be causing the navbar to start in a closed state?

Appreciate any insights, Jeff

<header id="home" class="jumbotron h-100vw w-100vw">
...
</header>
<div class="container-fluid">
<div class="row">
    <div class="col-md-2">
        <nav class="navbar navbar-expand-md navbar-light">

            <a class="navbar-brand" href="#home">
                <img src="img/logo.png" class="img-fluid" alt="Home">
            </a>

            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#nav-content" aria-controls="nav-content"
                aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse-md flex-column" id="nav-content">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="#about"></a>About Me</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#work">My Work</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#connect">Stay Connected</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#contact">Get In Touch</a>
                    </li>
                </ul>
            </div>
        </nav>
    </div>

    <main class="col-md-10">
        REST OF MY CONTENT ON THE RIGHT
    </main>
</div>

Answer №1

The class navbar-collapse-md does not exist. Please update it to navbar-collapse.

   <div class="collapse navbar-collapse flex-column" id="nav-content">
             <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="#about"></a>About Me
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#work">My Work</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#connect">Stay Connected</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#contact">Get In Touch</a>
                    </li>
             </ul>
   </div>

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

What steps should be taken to advance a group of students from one semester to the next?

In a scenario where I need to promote multiple students from semester 1 to semester 2 in one go, the current code logic seems to only handle promotion for single students. How can I modify it to accommodate batch promotion? -------------------Controller ...

Layout your Angular components with a column design using Flex Layout

Is there a way to adjust the width of a child component in an fxLayout set to column? Take this example for reference: https://stackblitz.com/edit/angular-fxlayout-custom-breakpoints?file=app%2Ftest.component.ts In the provided example, there are three f ...

Ways to pass a message from index.html to a Vue.js 3 instance

Picture this scenario: You have a Vue index.html file that also loads a custom script: <!DOCTYPE html> <html lang="en"> <head> ... ... <script type="text/javascript"> languagePluginLoader.then(fun ...

Eliminating unnecessary white space while utilizing the first-letter CSS property

Is there a way to remove the extra whitespace added under the first line when making the first letter of a paragraph bigger than the rest of the text? I already tried adjusting padding and margins on p::first-line without success. p{ line-height: 1.4; } p ...

I'm struggling to determine the source of the color for my linked CSS. Any ideas where to look?

I am experiencing an issue with a link that is displaying as white and gray for "a" and "a:hover", despite my CSS file specifying otherwise. Firebug confirms this, but I can't figure out what is overriding it. Can anyone offer any insight? Below is t ...

Tips for automatically displaying the scroll bar continuously on iOS 15 without requiring user interaction

We have a Web Application that displays a scroll bar for users to navigate through the content. The scroll bar functions correctly on desktop browsers and Android browsers, but not on Apple devices running iOS 15 (Safari Browser). Current Behavior : In ...

Give your screen a quick swipe with Ionic's pull-to-refresh

Is there a way to bring the footer of an ionic app closer for refresh or loading more content? I am particularly curious about how to implement the 'pull up to refresh' feature using HTML, CSS, or the Ionic content component. ...

utilizing the scss random feature to assign a randomly generated background hue

Despite reading numerous articles on this topic, I am struggling to implement a feature where a random color from a list is applied as the background image every time the page is refreshed. $red: #fc5545; $pink: #FCCCD1; $green: #005E61; $greenLight: #42B ...

Tips for positioning footer text to the left and right, similar to Google's style

Explore www.google.com for inspiration. You will notice a footer containing links to Advertising, Business, and About on the left side, and Privacy, Settings, Terms, etc. on the right side at the bottom of the page. I am an aspiring developer attempting ...

Container beyond div

Having an issue with the div extending beyond the container in Bootstrap 4. When a green div reaches the edge of the page, instead of being cut off it causes a horizontal shift in the page layout. How can this be avoided? Appreciate any assistance. Live ...

Tips for inserting the <a> HTML tag into a JSON array object

I am relatively new to creating array objects and I am unsure on how to add a link within a <a> tag in a JSON file. Here is the JSON object code: powerUpList: [ { id: 8, name: 'Automate your API column type ', description: & ...

What is the best way to incorporate Font Awesome icons into a UTF-16 encoded HTML document?

Trying to incorporate Font Awesome icons in UTF-16 encoded HTML pages can be a bit tricky. Following these steps should help you achieve the desired results: <head> <meta charset="UTF-8"> <link rel="stylesheet" href="https://use.fontawe ...

Python-JavaScript Integration Problem

I'm a beginner when it comes to Javascript, Python, and PHP. In my Javascript program, I have a button that triggers a Python script and displays the returned value on the screen. My goal is to steer clear of using Jquery and Json. Here are the snipp ...

Is window.getComputedStyle not functioning as anticipated?

Here is a function I created to determine the width and height of a text: function size_calculation(word,fontSize) { const div = document.body.appendChild(document.createElement('div')); div.textContent = word; div.style.cssText = ` fo ...

CSS trick that works on iOS16 as well

Previously, this CSS workaround was effective up to iOS version 15.6; however, it does not seem to be functioning in iOS 16. @media not all and (min-resolution:.001dpcm) { @supports (-webkit-appearance:none) {} } Are there any updated techniques avail ...

Utilizing jQuery's each() function to create a seamless loop of background images in a

Struggling with looping the background image in a slick slider? Check out the code snippet below. var json = [ { "img_url": "https://via.placeholder.com/500x500?text=1" }, { "img_url": "https://via.placeholder.com/500x500?text=2" }, { "img_url": "ht ...

Animating changes on a webpage using CSS transitions in conjunction with the

Can the border color of a simple line div be changed from top to bottom using GreenSock? .line { position: relative; border: 1px solid #c3ced8; width: 0; height: 50px; display: block; content: ''; z-index: 1; top: -19px; marg ...

Angular element fails to display properly

I'm currently working on developing a website using Angular and creating a header component. To generate the necessary files, I used the command ng g c commons/header which creates the HTML, SCSS, TS, and .spec.ts files. I then made modifications to t ...

A variety of personalized Vimeo play buttons

Recently, I stumbled upon a genius solution by Chris Coyier for creating custom Vimeo play buttons. It worked perfectly for my needs, but now I'm facing a challenge - how to make it function with multiple videos on the same page. I tried swapping out ...

css problem with footer in html5

Check out this code snippet for the footer section: <footer> <div class="footer"> <nav> <ul class="nav-list1"> <li><img src="img/notes.png" alt="img"></li> ...