Is Bootstrap's Mobile Menu Compatible with Tablets?

I'm struggling to modify my code in order for the navigation to collapse on mobile and tablet devices, but I can't seem to make it work. I attempted to adjust the @grid-float-breakpoint to 992px, however that did not have the desired effect. Any suggestions on where I might be making a mistake?

I've simplified the HTML for brevity, but I believe you'll understand the gist of it.

<div id="main-nav" class="row">
                <div class="header-wrap">
        <div class="site-branding">
                            <p class="site-title"><a href="#" rel="home">SITE TITLE</a></p>
                    </div><!-- .site-branding -->
        <nav id="site-navigation" class="main-navigation" role="navigation">
            <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button>
            <ul id="primary-menu" class="menu">
       <li class="menu-item menu-item-has-children dropdown">
        <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" href="#">Parent Link<b class="caret"></b>
        </a>
        <ul class="dropdown-menu">
          <li class="menu-item"><a href="#">Sub Link</a></li>
          <li class="menu-item"><a href="#">Sublink</a></li>
        </ul>
      </li>
     </ul>
  </nav>
  </div>
</div>

SCSS

.nav-menu {
  display: none;
  position: relative;
  top: 70px;
}
.dropdown-menu {
  display: none;
  position: static;
  width: 100%;
  li {
    width: 100%;
  }
}

.main-navigation.toggled {
  .nav-menu {
    width: 100%;
    display: block;
    background-color: #363636;
    li {width: 100%; display: block;background-color: #363636; text-transform: uppercase; border-top: .5px solid #434343;}
    li > a {
      padding: 8px;
      pointer-events: none; // prevent it's immediate A child to follow HREF
      cursor: default;
    }
    a {color: #fff;}
    .dropdown-menu {
      position:static;
      top: 80px;
      display: none;
      background: none;
      box-shadow: none;
      padding: 0;
      a {
        color: #fff;
        pointer-events: auto;
        cursor: pointer;
      }
      li {
        background-color: #000;
        a {
          width: 100%;
          &:hover {
            color: #000;
          }
        }
      }
    }
  }
}

@media (min-width: 992px) {
  #masthead:hover {
      padding-top:29px;
      background-color:$site-dark-gray;
      -webkit-box-shadow:0 0 8px rgba(0, 0, 0, 0.7);
      -moz-box-shadow:0 0 8px rgba(0, 0, 0, 0.7);
      box-shadow:0 0 8px rgba(0, 0, 0, 0.7);
      height:100px;
      .site-branding{
        width:240px;
        height:49px;
        @media (max-width: $screen-sm-max) {
          width:210px;
        }
        .site-title{
          a{
            width:167px;
            height:49px;
          }
        }
      }
      @media (max-width: $screen-xs-max) {
        padding-top:29px;
        height:100px;
      }
  }
  .main-navigation {
      .nav-menu {
        top: 0;
      }
        .dropdown-menu {
            visibility: hidden;
            display: block;
            opacity: 0;
            border-radius: 0;
            top: 3.15em;
            background-color: $site-dark-gray;
            // transform: translateY(-20px);
            transform: translateY(20px);
            transition: all .3s ease;
            left: -1.5em !important;
            overflow: hidden;
            padding: 0;
            border: 0;
        li:first-child {display: none !important;}
            li {
                margin: 0 !important;
                transition: all .3s ease;
                a {
                    padding-top: 8px;
                padding-bottom: 8px;
                }
                &:hover a {
                    color: #000 !important;
                    background-color: #fff;
                }
            }
            .active > a {
                    background-color: #fff;
                    color: #000 !important;
            }
        }

        .dropdown:hover .dropdown-menu {
                display: block;
                opacity: 1;
                visibility: visible;
                transform: translateY(0px);
        }
        .dropdown:after {
            content: "";
            display: block;
            height: 2em;
        position: absolute;
        top: 1em;
        width: 100%;
    }
  }
}

Answer №1

It appears that the issue might be due to the absence of the data-toggle="collapse" and data-target="#primary-menu" attributes on your navigation toggle button. These attributes are essential for determining whether the menu should be active or not. Take a look at how they are implemented in the example provided on Bootstrap's official website.

Answer №2

The most effective approach involves modifying scss by adjusting the variables within @grid-float-breakpoint

$grid-float-breakpoint:     $screen-md-min !default;

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

Steps for incorporating Bootstrap 5 pagination without using jQuery

Currently, I am working on incorporating pagination for cards using Bootstrap 5. My reference point is the following link: https://getbootstrap.com/docs/5.0/components/pagination/ While I can find the UI elements, I am struggling to come across a concrete ...

What are some ways to monitor the movement of elements and activate functions at precise locations?

I am working on a project that involves a #ball element which, when clicked, utilizes jQuery animate to move downwards by 210px. The code I currently have is as follows: $('#ball').click(function() { $(this).animate({ top: '+=2 ...

Background image loading gets delayed causing it to flicker

Instead of having separate files for different elements on my site, I decided to keep all the JavaScript in one large file called my_scripts.js. To speed up loading times, I defer the loading of this file using inline JavaScript and make sure it is the las ...

Content being pushed upward by Bootstrap modal

I've spent the last few hours working with the bootstrap modal, but I'm encountering some issues. Despite my thorough search, I haven't found anyone facing a similar problem. Here is the structure of my modal: <!-- Modal --> <div ...

"Step-by-Step Guide to Dividing and Centering Text Sections with Dynamic

Initially, my intention is to implement the concept outlined below. The webpage has dual potential states. In the first scenario, two texts (with potentially varying lengths) are centralized together as a header. When transitioning to the second state, the ...

Issue with rendering <li> elements in Firefox browser detected

I have been working on a website and encountered an issue with the display of list elements in Firefox. The list is not showing consistently in Firefox, but it appears fine in IE, Opera, and Safari. I have attached an image below showing the difference bet ...

I must align a bootstrap modal(dialog) based on the opener's position

Using a bootstrap modal for the settings dialog in an angularJS app, but facing an issue where it opens in the center of the page by default instead of relative to the opener. Looking for a solution to keep it positioned correctly when scrolling. Code: M ...

What could be causing site container not to respond to height:auto?

I have encountered an issue while developing a website using absolute height values. I am puzzled as to why the height:auto property is not working for me. Can anyone provide some insight on this? HTML Structure <div id="site-content"> <div id=" ...

Help! Enabling "authorization" feature is causing CSS to malfunction. How can this issue be resolved?

When I include the following code: <deny users="?"/> inside the "authorization" tags, CSS stops working for unauthorized visitors. Is there a way to create an exception for CSS files so that they apply to all visitors? This is what my web.config f ...

Tips for incorporating API-provided CSS values into AngularJS expressions for stylish card customization

I am in the process of creating unique Pokemon cards that pull data from an API. My question is, how can I apply specific CSS styling to each card directly from the API, similar to how I have utilized AngularJS to render the information? So far, I have su ...

How can I create a Bootstrap 4 navigation menu that toggles on the left side but keeps the button on the right

Is it possible to create a collapsible bootstrap 4 navigation with the toggle button on the left side while also having action buttons on the right side that are not part of the collapsible menu? How can I prevent the navbar-collapse menu from pushing down ...

Reposition div when clicked

I have encountered a challenge where I am unable to perform a small task. My goal is to have the position of "div1" change upon clicking on "div2", taking into account that "div2" is nested inside "div1". Additionally, when clicking on "div2" again, "div1" ...

JSFiddle Functioning Properly, But Documents Are Not Loading

My JSFiddle is functioning properly, but the files on my computer aren't. It seems like there might be an issue with how they are linking up or something that I may have overlooked. I've checked the console for errors, but nothing is popping up. ...

ASP.NET Core 3.1 dynamic image resizing

<div class="col-md-6"> <div class="border"> <img height="300" width="400" src="~/Images/vg.png" class="rounded"/> <p>This is a sample paragraph.</p&g ...

What is the best way to set a specific image as the initial image when loading 'SpriteSpin'?

I'm currently working on creating a 360-degree view using the SpriteSpin API. Everything is functioning as expected, but I have an additional request. I need to specify a specific image to be the initial landing image when the page loads. The landing ...

Leverage the power of Bootstrap 4 without incorporating its pre-built components

Is it possible to utilize Bootstrap 4 without its components? The diagram below seems to suggest otherwise, correct? My Scenarios: I need to implement Angular Material components instead of Bootstrap components. It's acceptable to use Bootstrap 4 ...

What is the best way to animate an element when it comes into the user's view

In order to activate the animation of the skill-bars when the element is displayed on the website, I am seeking a solution where scrolling down through the section triggers the animation. Although I have managed to conceptualize and implement the idea with ...

Creating a mandatory 'Select' component in Material UI with React JS

Is there a method to show an error message in red until a choice is selected? ...

Issue with displaying Bootstrap Tooltip

Recently, I launched a fresh website (currently residing on a sub-domain). However, I am facing an issue with the tooltip not showing up when hovering over the text Get the FinEco Bookmarklet. <span class="bookmarklet"><span class="fa fa-bookmark ...

CSS animation causing font-size rendering issues

I attempted to create a sentence where specific words are animated (rotated through) - initially it seemed to be working fine. However, upon checking the site on my mobile device, I discovered an issue. When accessing the page from a desktop ( including wi ...