Issue with the show transition of collapsed non-navbar element in Bootstrap v4.3 Navbar not animating properly

Recently, I developed a customized pills menu system that showcases a collapsed structure on smaller screens and mobile devices. The problem I encountered is when the 'menu' button is clicked, the pill items don't show up with a smooth transitional effect as expected. Instead, it takes approximately half a second to appear, which is less than ideal. It appears that the transition operates relative to the navbar, requiring some adjustments for manual hidden element display in my example below:

.xs-collapse {
  display: none;
  
}

body {
  background-color: aqua;
}

@media (min-width: 992px) {
  .xs-toggle {
    display: none;
    visibility: hidden;
  }
  .xs-collapse {
    display: block; 
  }
}
<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    
    <title>Hello, world!</title>
  </head>
  <body>
   
    <div class="container">
      <div class="row">
        <div class="col-lg-4">
          <nav class="navbar navbar-expand-lg navbar-light bg-light  xs-toggle">
              <a class="navbar-brand" href="#">
                  <img src="./images/logo.svg" height="40" class="d-inline-block align-top" alt="">
              </a>
              <button  class="navbar-toggler" type="button" data-toggle="collapse" data-target="#v-pills-tab" aria-controls="v-pills-tab" aria-expanded="false" aria-label="Toggle navigation">
                  <span class="navbar-toggler-icon"></span>
              </button>
          </nav>

            <ul class="nav flex-column nav-pills xs-collapse collapse" id="v-pills-tab" role="tablist" aria-orientation="vertical">
                <li><a class="nav-link active" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</a></li>
                <li><a class="nav-link" id="v-pills-profile-tab" data-toggle="pill" href="#v-pills-profile" role="tab" aria-controls="v-pills-profile" aria-selected="false">Profile</a></li>
                <li><a class="nav-link" id="v-pills-messages-tab" data-toggle="pill" href="#v-pills-messages" role="tab" aria-controls="v-pills-messages" aria-selected="false">Messages</a></li>
                <li><a class="nav-link" id="v-pills-settings-tab" data-toggle="pill" href="#v-pills-settings" role="tab" aria-controls="v-pills-settings" aria-selected="false">Settings</a></li>
            </ul>
        </div>

        <div class="col-lg-8">
            <div class="tab-content" id="v-pills-tabContent">
                <div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab">...</div>
                <div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab">...</div>
                <div class="tab-pane fade" id="v-pills-messages" role="tabpanel" aria-labelledby="v-pills-messages-tab">...</div>
                <div class="tab-pane fade" id="v-pills-settings" role="tabpanel" aria-labelledby="v-pills-settings-tab">...</div>
              </div>
        </div>
      </div>
    </div>

    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    
  </body>
</html>

The current functionality of the menu item isn't working flawlessly, and any assistance in resolving this issue would be highly appreciated.

Thank you!

Answer №1

Here is the relevant code snippet for your reference, providing you with a hint in the right direction.

<nav class="navbar navbar-dark bg-dark">
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
</nav>
<div class="collapse" id="navbarToggleExternalContent">
    <div class="bg-dark p-4">
        <h4 class="text-white">Collapsed content</h4>
        <span class="text-muted">Toggleable via the navbar brand.</span>
    </div>
    <ul class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
        <li><a class="nav-link active" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</a></li>
        <li><a class="nav-link" id="v-pills-profile-tab" data-toggle="pill" href="#v-pills-profile" role="tab" aria-controls="v-pills-profile" aria-selected="false">Profile</a></li>
        <li><a class="nav-link" id="v-pills-messages-tab" data-toggle="pill" href="#v-pills-messages" role="tab" aria-controls="v-pills-messages" aria-selected="false">Messages</a></li>
        <li><a class="nav-link" id="v-pills-settings-tab" data-toggle="pill" href="#v-pills-settings" role="tab" aria-controls="v-pills-settings" aria-selected="false">Settings</a></li>
    </ul>
</div>

Check out the fiddle link 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

Utilize Three.js to seamlessly incorporate mesh information directly into your code

Here's my Three.js code that loads a mesh from the file /models/mountain.json using a JSON loader: var Three = new function () { this.scene = new THREE.Scene() // Camera setup this.camera = new THREE.PerspectiveCamera(45, window.innerWid ...

Incorporating JQuery UI sortable functionality with the CSS grid display property to create a

I'm currently working on creating a sortable CSS grid using jQuery UI. $( function() { $( "#sortable" ).sortable({ handle: "handle" }); }); gridHolder{ display:grid; background:tan; grid-template-columns: ...

What is the significance of the colon found within a VueJS/Vuetify/HTML component tag?

Incorporating Vuetify into my project has led me to this VueJS, Vuetify, or HTML inquiry. The component in question displays as follows: <v-list-tile v-for="item in menuItem.items" :key="item.type" :style="`background: ${item.colour}`" :h ...

The command I gave is not being executed

I am attempting to replicate the functionality of nsClick with my custom directive by changing its priority. Here is my directive code: angular.module('MyApp').directive('nsClickHack', function () { return { restrict: 'E' ...

Angular compatibility issue with Bootstrap 4 tooltip feature

Can anyone help me with the error I'm encountering below? I am working with Bootstrap 4 and Angular 7. Error Description: error TS2339: Property 'tooltip' does not exist on type 'JQuery'. ngAfterViewInit() { jQuery(this. ...

What is the most effective method for postponing the loading of JavaScript?

Incorporating a bootstrap theme into my project has required me to include several javascript files. The challenge arises when some pages load dynamic content from the server, resulting in the entire HTML not being present when the javascript files are exe ...

Issue with the search term functionality in the Select2 remote source dropdown field

In my city field, I have an inlinedit function that loads ajax data on a dropdown list. However, when I type a term, it does not automatically select the result. For instance, if I type "pabna", it should auto-select the option with "pabna" but currently, ...

What is the best way to bring an array consisting of a class to life through animation in three.js?

I am currently exploring the world of three.js and experimenting with some basic concepts. One thing I have been working on is a class that generates cubes in random locations and populates an array with these cubes using a for loop. My goal is to animate ...

What strategies are available for managing intricate nested data conversions in TypeScript with lodash?

I am currently developing a TypeScript project that involves performing intricate transformations on deeply nested JSON data. While I am utilizing lodash for utility functions, I have encountered a challenge in the following scenario: { "users" ...

Using JavaScript regex with optional match on either the left or right side

Hello, I am having trouble getting my pattern to work correctly. My goal is to detect if a specific word has any word or letter either on the left side, right side, or both sides. For example: a{placeholder} = found {placeholder}b = found a{placeholder} ...

Implementing standard Header and Footer elements in Vue.js single-page applications

I'm currently working on a VueJS project for a spa. I've already created common components for the Header and Footer, and now I want to include them in the main App.vue file. Here is the structure of my code: https://i.sstatic.net/qdLam.png Le ...

Troubleshooting Selenium JS: Challenges with Locating Elements Across Pages

I'm facing a challenge in accessing elements on pages other than the main page in my electron app. Although there are multiple elements that load when the app starts, I can only interact with elements on the initial page. I believe the issue lies in h ...

Log out from Google using API with JavaScript or jQuery

I am looking for a way to implement a Logout option in my web application using the Google API JavaScript Client Library. I have successfully integrated the auth command for user login, but now I need help with logging out of both my application and the us ...

Problem with changing the font size in the editor

My implementation of the Ace- Editor looks like this: <div id="AceEditor"></div> The blue area acts as my editor, with the following CSS styling: #AceEditor { position: absolute; top: 0; right: 300px; bottom: 420px; lef ...

Struggling to target the child elements of an unordered list with jQuery?

Need help with selecting the children of a list item in a jQuery mobile navigation? I am having some trouble with this task. Here is a fiddle demonstrating what I have done so far: http://jsfiddle.net/jhrz9/ <div data-role="panel" id="left-panel" data ...

Transmitting an array of HTML form data to JSP/Servlet

My background is in PHP, where form data with names ending in square brackets are automatically interpreted as arrays. For example: <input type="text" name="car[0]" /> <input type="text" name="car[1]" /> <input type="text" name="car[3]" /&g ...

Is it possible for me to transform this code into a useful helper function?

I am looking to optimize this conditional code by converting it into a helper function using a switch statement instead of multiple if statements. How can I achieve this in a separate file and then import it back into my component seamlessly? import { ...

Step-by-step guide on integrating the Tawk chat widget script into a Next.js React application

I am currently working on integrating a chat widget from Tawk into a next.js react app. In my _app.js file, I have added the script import tag and attempted to set up the widget like this: import Script from 'next/script' {/* <!--Start ...

When a user clicks on an anchor tag, the corresponding value of the checked item is then returned

I have 3 sets of radio buttons. When a specific anchor with the "round" class is clicked, two actions should occur: The associated set of radio buttons needs to become visible The value of the checked input for that element should be returned. I am ...

Transition Effect for Sub Menu Hover in Google Chrome

The top menu bar on my website has a second level dropdown that is functioning correctly in Firefox but not in Chrome. In Chrome, when I mouse out of the dropdown, the background color disappears before the links. This creates a slight timing gap between ...