Bootstrap Toggle appears on screens of medium size

While working on creating a responsive dashboard with Bootstrap 4.3, I encountered an issue specifically with medium screens. Upon resizing Google Chrome to test the page at various sizes, I noticed that the bootstrap toggle button would unexpectedly appear when the browser was in medium size. This behavior was consistent across different browsers. The screenshot below illustrates how the screen size is not small enough for the content to disappear and trigger the toggle button:

https://i.sstatic.net/rfVbd.png

Below are excerpts from my code. Any assistance in resolving this problem would be greatly appreciated.

@media (max-width: 768px) {
.sidebar {
position: static;
height: auto;
}
.top-navbar {
position: static;
}
}
.top-nav-height {
height: 3em!important;
}
.sidebar {
box-sizing: border-box;
background-color: #34495e !important;
height: 100vh;
}
<body dir="rtl">
<!-- Navigation -->
<nav class="navbar  navbar-expand-lg navbar-light p-0 m-0">
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#goNavBar" aria-controls="goNavBar" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="goNavBar">
        <div class="container-fluid">
            <div class="row">
               <!-- Sidebar -->
                <div class="col-md-2 col-xl-2 col-md-5 sidebar p-0 m-0">
                    <a href="#" class="text-white d-block  pt-3 pb-3 h5 text-decoration-none text-center">ِDashboard</a>

                    <div id="NavBarParent">
                    <ul class="navbar-nav flex-column">
                        <li class="nav-item rtl d-block">
                            <a href="#" class="nav-link sidebar-menu sidebar-both-border pr-4"><i class="fas fa-home ml-2"></i>Home</a>
                        </li>
                            </ul>
                    </div>

                </div>
                <!-- Sidebar Done -->

                <!-- Top Bar -->
                <div class="col-md-10 col-xl-10 col-md-7 py-3 top-navbar">
                    <div class="row align-items-center">
                        <div class="col-md-4 col-sm-4 col-lg-5 col-xl-5">
                            <h4></h4>
                        </div>
                        <div class="col-md-5 col-sm-4 col-lg-5 col-xl-5">
                        </div>
                        <div class="col-md-3 col-sm-4 col-lg-2 col-xl-2" >
                            <ul class="navbar-nav">
                               
                                <li><span class="fa-layers fa-fw fa-lg" >
                                    <i class="fas fa-envelope py-1" style="color: #34495e"></i>
                                    <span class="fa-layers-counter fa-lg bullet-sizing">45</span>
                                </span></li>
                                <li><span class="fa-layers fa-fw fa-lg mr-2" >
                                    <i class="fas fa-bell py-1"  style="color: #34495e"></i>
                                    <span class="fa-layers-counter bullet-sizing fa-lg">2</span>
                                </span></li>
                                <li class="nav-item mr-auto"><a href="#" class="nav-link"><i class="fas fa-sign-out-alt fa-lg"  style="color: #34495e"></i></a></li>

                            </ul>
                        </div>
                    </div>
                </div>
                <!-- Top Bar Done -->
            </div>
        </div>
    </div>
</nav>
<!-- Navigation Done -->

To simplify things, I omitted some lines related to sidebar menu items as those were deemed irrelevant to the sizing and toggle button issue.

Answer №1

It's amazing how a simple change in the code can solve a big issue. By switching 'navbar-expand-lg' to 'navbar-expand-sm' on the initial line, I was able to fix my problem right away.

Answer №2

To adjust the navigation bar size, you can modify the classes navbar-expand-(value)Ex lg/md/sm or custom in your code. Here's an example with the changes:

<body dir="rtl">
<!-- Navigation -->
<nav class="navbar  navbar-expand-md navbar-light p-0 m-0">
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#goNavBar" aria-controls="goNavBar" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="goNavBar">
        <div class="container-fluid">
            <div class="row">
               <!-- Sidebar -->
                <div class="col-md-2 col-xl-2 col-md-5 sidebar p-0 m-0">
                    <a href="#" class="text-white d-block  pt-3 pb-3 h5 text-decoration-none text-center">ِDashboard</a>

                    <div id="NavBarParent">
                    <ul class="navbar-nav flex-column">
                        <li class="nav-item rtl d-block">
                            <a href="#" class="nav-link sidebar-menu sidebar-both-border pr-4"><i class="fas fa-home ml-2"></i>Home</a>
                        </li>
                            </ul>
                    </div>

                </div>
                <!-- Sidebar Done -->

                <!-- Top Bar -->
                <div class="col-md-10 col-xl-10 col-md-7 py-3 top-navbar">
                    <div class="row align-items-center">
                        <div class="col-md-4 col-sm-4 col-lg-5 col-xl-5">
                            <h4></h4>
                        </div>
                        <div class="col-md-5 col-sm-4 col-lg-5 col-xl-5">
                        </div>
                        <div class="col-md-3 col-sm-4 col-lg-2 col-xl-2" >
                            <ul class="navbar-nav">

                                <li><span class="fa-layers fa-fw fa-lg" >
                                    <i class="fas fa-envelope py-1" style="color: #34495e"></i>
                                    <span class="fa-layers-counter fa-lg bullet-sizing">45</span>
                                </span></li>
                                <li><span class="fa-layers fa-fw fa-lg mr-2" >
                                    <i class="fas fa-bell py-1"  style="color: #34495e"></i>
                                    <span class="fa-layers-counter bullet-sizing fa-lg">2</span>
                                </span></li>
                                <li class="nav-item mr-auto"><a href="#" class="nav-link"><i class="fas fa-sign-out-alt fa-lg"  style="color: #34495e"></i></a></li>

                            </ul>
                        </div>
                    </div>
                </div>
                <!-- Top Bar Done -->
            </div>
        </div>
    </div>
</nav>
<!-- Navigation Done -->

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

Tips for adjusting the color using inline CSS

Currently, I have a div styled with blue color using CSS. However, I now require the ability to dynamically change this color. My plan is to retrieve the desired color from a database and use its hexadecimal code in place of the default blue. What is the ...

Positioning the filters in jQuery Datatables

I'm currently working with jQuery datatables and I'm attempting to align the filter/search box on the same row as the header of the container holding the datatable. Attached is a screenshot for reference: https://i.stack.imgur.com/nzbIl.png He ...

What is the best way to extract a single image from JSON data using AngularJS?

Using ng-repeat in HTML, how can I display only a single image instead of all images? <img class="size" ng-src="{{image.image}}" /> In CSS, I aim to define the size of the image. .size { margin-left:0.3em; width:11em; height:11em; border:0.4em sol ...

Bootstrap column height problem arises when the second column contains added margin, padding, or is wrapped in another element

I am facing an issue with a two-column layout where one column serves as the page heading (left) and the other displays breadcrumbs (right). The problem arises when the first column fails to stretch its height fully due to padding or margin in the second c ...

Troubleshooting the sidebar pin-unpin problem using Jquery and CSS

I have created a single side panel that allows me to toggle between opening and closing the sidebar by hovering on it. I can also pin and unpin the sidebar by clicking on the pin image. Now, I want to open the sidebar onClick instead of onHover and remove ...

Using Sass to Loop through Specific Items

Currently, I am in the process of developing a SASS loop to iterate over a series of images (let's say 50). My goal is to increment the transition delay by 50ms for every nth-of-type image. However, it appears that the current for loop I have implemen ...

What is the reason that elements with % properties totaling 100% do not align next to each other?

I've been attempting to arrange two blocks side by side within another block, but they just don't seem to fit together smoothly. What could be causing this issue? .container {height: 200px; width: 400px; background:darkgrey;} .left {height: 100% ...

Ways to optimize the spacing between the menu bar and widgets

I have successfully incorporated multiple images side by side on my blog Following is the code used for this layout: <div class="images"> <figure> <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSA7XLfGrT1rMS-Ifoguz-X2igsT ...

What is the best way to make the final character in the input placeholder appear in red?

Here lies my input field https://i.sstatic.net/0mJyJt.png, I'm striving to make the last character '*' appear in bold red rather than blending into the background. Despite numerous attempts, I haven't been successful in achieving the d ...

Issues with the navigation and logo design in bootstrap mode

1: How can I adjust the size of the logo and name in my Bootstrap navigation? 2: My navigation menu is not showing up correctly. Can anyone help me troubleshoot? https://i.sstatic.net/0pXya.jpg Navbar: <nav class="navbar navbar-expand-lg py-4 f ...

Is it possible to manipulate an image tag's image using only CSS?

Is it possible to hide an image from the src attribute of an <img> tag and instead set a background image on the tag using CSS? One idea could be adjusting the positioning or text-indent of the actual image to move it out of view, and then applying ...

Discrepancy detected in AGM Map printout

When attempting to print my Angular AGM Map from Chrome, I noticed a large grey gap in the map. This gap is visible even when "background graphics" are turned off and it causes the map image below it to shift downwards. If you want to reproduce this issue ...

Failure to Connect HTML with Stylesheet

Feeling a bit lost here. I've been attempting to connect my homepage to my stylesheet, but no matter how often I refresh the page, it just won't recognize the link. I'm diligently following the instructions from the guide I have, copying and ...

Adjusting ToggleButton hues in react-bootstrap

I am working with a group of ToggleButtons in my app and I want to customize their background colors. Currently, all the buttons have a gradient defined by <.untoggled-button> class, with an added blue overlay for unselected buttons. However, I am fa ...

What is the best way to superimpose text on a variety of images with varying sizes using CSS

I have a client who is requesting a sold text to be displayed on top of all images that have been sold, positioned in the bottom left corner of each image. While I have successfully implemented this feature, the issue arises when dealing with images of var ...

center menu items will be displayed as a fallback in case flexbox is unavailable

The code I have creates space between menu items and centers them both horizontally and vertically within each item. This is achieved by using a wrapper for the menu items: .gel-layout { list-style: none; direction: ltr; text-align: left; ...

Troubleshooting: When Angular Fade In Out Animation Won't Work

Looking to create a simple animation with the angular animation package The goal is to smoothly transition from opacity 0 to opacity 1 for a fade effect. I've had success with other properties like height and display, but struggling with opacity. H ...

Utilize the div element to segment a webpage into four different sections

Within a div tag, I have used 4 other div tags to create equal areas. Is there an alternative method to achieve this division or improve it? <div style="width: 689px; margin-left: 215px; margin-top: 0px; float: none; height: 502px;"> ...

Ways to create distance between repeated cards in a loop. My method involves utilizing ajax, jquery, and bootstrap

view image description here What is the best way to create some space between these closely aligned cards? .done((todos) => { todos.forEach(el => { console.log(el) $("#todo-list").append(` <d ...

Tips for incorporating a background color into a specific section

Code: .headline { font: 150 50px/0.8 'Pacifico', Helvetica, sans-serif; color: #2b2b2b; text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.1), 7px 7px 0px rgba(0, 0, 0, 0.05); text-align: center; } <link href='http://fonts.googleapis.com ...