Collapsed navbars in Bootstrap 5 fail to display properly in a two-column format

Looking to create a responsive Bootstrap 5 navbar that collapses at the md breakpoint and displays navlinks in two columns upon collapse. Currently facing an issue where the navbar remains expanded and the toggle button fails to work after hitting the breakpoint. Disabling the display: flex property resolves the collapse functionality but results in the ul's, housing li elements, being displayed in a single column. How can I achieve my desired outcome - collapsing the six-element navbar at the md breakpoint while breaking the links into two columns?

<nav class="navbar navbar-expand-md navbar-light sticky-top w-100">
<div class="container-fluid">

...

The rest of the code remains unchanged for the css optimizations.

Answer №1

Your CSS usage is a bit unclear without a running snippet provided with your question. However, here are some suggestions based on the information available:

  • To center your logo, consider splitting your menus into two unordered lists.
  • Utilize Bootstrap's spacing utility classes like mb-1 mb-md-2 for applying margins to elements like navbar-nav.
  • When using media queries from Bootstrap, remember to prioritize min-width over max-width and start with smaller sizes before moving up.
  • Instead of shrinking text for smaller screens, maintain the same size and adjust positioning as needed for better readability.

If you want two columns in the collapsed version of links, consider adding a spacer div (`.break`) between `navbar-collapse` items and setting their width to 50%.

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d3b1bcbca7a0a7a1b2a393e6fde3fde2">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css2?family=Quicksand&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3a5855554e494e485b4a7a0f140a140b">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>

<style>
    /* Insert your customized CSS here */
</style>

<nav class="navbar navbar-expand-md navbar-light sticky-top w-100">
    <!-- Navbar structure goes here -->
</nav>

<section>
    <div class="container">
        <div class="row">
            <div class="col vh-100">
                <p class="text-center">
                    Center
                </p>
            </div>
        </div>
    </div>
</section>

Consider including a placeholder image sized correctly to match your logo for better visual representation (e.g., 120x40 pixels).

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

The functionality of the Bootstrap dropdown list button is not functioning properly on mobile devices

Currently, I am in the process of developing a website and testing its mobile view on my iPhone. The website is still using bootstrap 3, but I have encountered some issues. When I tap on the navigation button on my iPhone, nothing happens - no dropdown lis ...

The include_once function is functioning correctly on one page, but encountering issues on another page. No errors are being displayed

I am currently using Bootstrap for my website. When I include the bottom and footer sections in actualites.php (at the end of the file), everything works smoothly. As I construct my website, I am trying to incorporate content via URL. My code looks like t ...

Instructions on deactivating the background when the sidebar is displayed and closing the sidebar by clicking anywhere other than the sidebar

I'm in the process of creating a sidebar for my website. When the sidebar is displayed (by clicking showRight), I want to disable the background content so that the user can't interact with anything outside of the menu. If the user clicks on th ...

Bootstrap's inline form features a button on a separate line from the rest of the form

I grabbed this code directly from bootstrap's official documentation: <form class="form-inline"> <div class="form-group"> <label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label> <div class="inp ...

align the horizontal navigation bar

I am facing an issue with my horizontal navigation bar. I want to include a search bar within the navigation bar, but it is causing misalignment. Here is the link to the code: https://jsfiddle.net/r6ntxg2f/ If you look at the menu, you will notice that i ...

How can you make the second block element in a pair stretch to fill the parent element?

I'm currently struggling to make the "rightcol" in the "wrapper" of my data-entry form fill the remaining space next to the second column. Despite successfully displaying the child elements properly, whenever I use the border-bottom attribute, the bor ...

Why is it important to have specific property names?

Here is some code and HTML for triggering a radio button. It seems to work fine without any issues, but I'm wondering if the presence of a name property is necessary. When I remove the name property, it stops working. Can someone explain why? <inp ...

Issue with Hover Effect on Safari Browser

Encountering a peculiar issue exclusively in Safari - when hovering over a link in the header, the links to the right of the hovered-over link alter their size (appearing smaller) during the hover animation. Once the animation concludes, these links revert ...

Is there a specific code repository available that can verify and transform blog comments into XHTML strict format?

I'm currently developing a PHP website that allows users to make comments similar to a blog, and I am specifically interested in restricting the use of certain HTML tags. Is there any existing library that can process user comments and output valid XH ...

The error message "Cannot read property 'option0' of undefined" occurs when using Node.js with Express and EJS

script.js var choices = { choice0: 11, choice1: 'choice1', choice2: 'choice2', choice3: 'choice3', choice4: 'choice4', choice5: 'choice5', choice6: 'choice6', choice7: 'choice7', choice ...

Ending the Overlay

I am using an overlay: <div id="overlayer" class="overlayer"> <div id="board" class="board"></div> </div> Here are the CSS properties I have applied to it: #overlayer { position:fixed; display:none; top:0; left:0; width:100%; hei ...

Issue with TinyMCE Editor: Inoperative

<script type="text/javascript" src="<your installation path>/tinymce/tinymce.min.js"></script> <script type="text/javascript"> tinymce.init({ selector: "textarea", theme: "modern", plugins: [ "advlist autolink li ...

Disabling the Entire Page Using Jquery

I've got this cool ajax function function do_ajax_request(t){ var form = $('#edit_'+t); var loadingDiv = $('#loading_'+t); $.ajax({ url: form.attr("action"), type: "POST", data: form.serialize(), cach ...

Modify top position without affecting bottom alignment using CSS

I am currently working on a website that is designed to mimic a printable document. The layout consists of a header, body, and footer, with each element utilizing CSS for margin and height adjustments. The challenge lies in ensuring that the footer is alw ...

Creating a dual-column checkbox design with CSS only

I'm working with a dynamically generated form element that can only be styled using CSS. I need help achieving a specific layout without making any HTML changes, except for the classes. The "element" and "formField" classes are common and cannot be mo ...

What are some effective ways of using the parent, before, and children selectors?

<table> <tr><td><input type="text" value="123"></td><td><input class="here" type="text"></td></tr> <tr><td><input type="text" value="333"></td><td><input class=" ...

Utilize a SCSS class defined in one file within a different SCSS file

In my React project, I have a day/night theme button that changes the main body color in the App.scss. It's a simple setup using body.light and body.dark. However, I need to also change the text color in the navigation bar, which is located in a diffe ...

What could be causing the .hover function to malfunction and how can I make it so that the .hover function only applies within the corner radius area?

I am attempting to make circles react to my jquery .hover function. Below is the JavaScript code I am using: jQuery.fn.center = function () { this.css("position","absolute"); this.css("top", Math.max(0, (($(window).height() - this.outerHeight()) / 2) + ...

Techniques for breaking down large CSS files into modules and combining multiple smaller CSS files

My website's CSS file is currently massive, containing site-wide selectors in a file named Mondo.css. While this setup has been effective for ensuring users only need to download the file once, I've recently developed a widget that requires its o ...

URL for CSS Background-Image

While working on CSS styling for the body, I ran into a problem and was curious to understand the distinction. Initially, I tried this body { background-image: url('img/bg.png'); } However, it did not produce the desired result. http://www ...