In the realm of Bootstrap 4, the nav collapsing animation briefly hesitates when opening but smoothly closes without any interruptions

The menu expands smoothly when opened but has a slight pause before continuing to slide down. Closing the menu seems to be smoother compared to opening it.

.navbar {
  padding: 0;
  float: right;
}

.navbar.fixed-top {
  left: auto;
}

.navbar-menu {
  position: relative;
  padding: 12px 17px;
  margin: 20px;
  background: #FFFFFF;
  cursor: pointer;
  z-index: 20;
  height: auto;
  border-radius: 2rem;
}

@media (max-width: 767.98px) {
  .navbar-menu {
    margin: 10px;
  }
}

.navbar-menu .title {
  font-size: 14px;
  font-weight: 700;
  color: #351C81;
…

<ul class="navbar-nav">
    <li class="nav-item active">
      <a class="nav-link" href="#">Home</a>
    </li>
…
  transition: all 0.25s;
  filter: alpha(opacity=100);
…
</div>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-…

<nav class="navbar fixed-top" data-aos="fade-left" data-aos-delay="500">
  <div class="navbar-menu" data-toggle="collapse" data-target="#navigation" aria-expanded="false" aria-controls="navigation">
    <span class="title">Menu</span>
    <div class="navbar-toggler">
      <span></span>
      <span></span>
      <span></span>
      <span></span>
    </div>
  </div>
</nav>

…
  </ul>
</div>
…

Answer №1

After noticing a significant amount of unnecessary absolute positioning in the code, particularly to adjust items on the screen and center them within other elements, I identified that this was causing Bootstrap's toggle JavaScript functionality to misunderstand the height of expanding elements.

Instead of using absolute positioning for .navbar-collapse to always span the entire window, I suggested setting the height of its contents to be equal to the window height - accomplished by applying height: 100vh to .navbar-nav.

Furthermore, since Bootstrap already uses display: flex for .navbar-nav, I removed the absolute positioning and added justify-content: center to vertically center the list elements inside it.

To view a comparison of my CSS changes with the original version, please click on the following link: https://i.sstatic.net/7ikTa.png

You can also see a working example below:

... (CSS code modifications)
... (HTML code snippets)

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

Jest encountered a TypeError stating that the function $(...).modal is not recognized

I am currently testing my Rails/React application using Jest. Within my Restaurant component, I am calling a modal using $('.modal').modal(); in the ComponentDidUpdate lifecycle method. Restaurant.js class Restaurant extends Component { cons ...

Exploring the world of unit testing for Sails JS 1.0 helper functions

Currently, I am in the process of setting up unit testing for my SailsJS 1.0 application. My goal is to simulate the DB without needing to execute 'sails lift' to run tests. In my application, there is a straightforward actions2 (node machine) h ...

What is the best method for centering text input within an Angular Material toolbar?

Can anyone help me with aligning input elements with buttons on an Angular Material toolbar? Check out the code pen: http://codepen.io/curtwagner1984/pen/amgdXj Here is the HTML code: <md-toolbar class="md-hue-1" layout-align="start center" style="mi ...

Navigating React Router: Updating the page on back button press

Looking for a solution to a persistent issue. Despite various attempts and exhaustive research, the problem remains unresolved. Here's the situation: Within my React-Router-Dom setup, there is a parent component featuring a logo that remains fixed an ...

How to change a CSS 'left' property using Jquery or Javascript

Upon examining my DOM, I found the following element: <div id="itemEditor" class="quoteItemEditorView partType_MATERIAL editMode selectorEnabled" style="left: -1px; right: 0px; width: auto; min-width: 480px; display: block;" > I have b ...

I'm having issues with my flipclock moving too quickly and skipping over certain numbers. Any suggestions on how to resolve this issue?

My flip clock script is behaving oddly, moving too quickly and skipping over even numbers. I've been playing around with the code, and it seems like there's a problem when I use the callbacks function. var clock = $('#clock3').FlipClo ...

Tips for calculating the total of a virtual column through child associations in Sequelize

I have a network of 3 interconnected objects (A, B, and C). There can be multiple Bs associated with A, and multiple Cs associated with each B. For instance: A └───B │ └───C │ └───C └───B └───C Object ...

Displaying identification when clicked using JavaScript

Hey there, I've been searching for an answer to my issue but haven't had any luck so far. Can anyone assist me? I have a group of links that display specific ids when clicked. It's working fine, but one link should actually trigger the disp ...

Banana: Eliminate linked IDs using purgeMany trigger

Here is an example of my schema structure: const Author = new Schema({ name: String, posts: [{ type: mongoose.Schema.Types.ObjectId, ref: "Post" }] }); const Post = new Schema({ text: String, author: { type: mongoose.Schema.Types.ObjectId ...

Having trouble with the dropdown onclick event not triggering when an item is selected in React?

I am having an issue where the onclick event handler is not being called when a dropdown item is selected. In my code, I am generating a dropdown inside a loop in the componentDidMount() lifecycle method. I am passing an event handler function named "show ...

What is the best way to retrieve all collections and their respective documents in Firestore using cloud functions?

Seeking to retrieve an array structured as [1year, 1month, etc] with each containing arrays of documents. Currently encountering a challenge where the returned array is empty despite correct snapshot sizes. Unsure if issue lies with push() method implemen ...

Play multiple videos simultaneously on a single webpage automatically

Looking to enhance my archive product page in woocommerce by adding a featured video. Encountering an issue where only one video auto plays while the others pause. When there's just one video on the page, it works flawlessly, but adding a second vide ...

Both paragraphs are on the same line

.footer { position: fixed; left: 0; bottom: 0; width: 100%; background-color: #3498DB; color: white; text-align: cent ...

Error encountered when attempting to send JSON data with special characters via a POST or PUT request using node.js's http.request()

While attempting to use the node.js http module to PUT a JSON data into CouchDB, I encountered an issue. The JSON included a special character "ä" which caused CouchDB to respond with an "invalid_json" error. However, once the special character was remove ...

Tips for transferring a function between stateful and stateless components

Looking to transfer a function from a stateful component to a stateless component, here's a snippet of the code. Below is the stateless code. const ProductsGridItem = props => { const { result } = props; const source = result._source; return ( ...

The outline of a box with the title "CSS, FrontEnd Dev - UX" is a key

Struggling with UX design here. Working on an app in React with Material UI, aiming for a look similar to this: https://i.sstatic.net/h1alm.png My goal is to make the "Some Title" section dynamic from my database, along with the contents. Can't seem ...

Leverage TypeScript generics to link props with state in a React class-based component

Can the state type be determined based on the prop type that is passed in? type BarProps = { availableOptions: any[] } type BarState = { selectedOption: any } export default class Bar extends React.Component<BarProps, BarState> { ...

Tips for positioning slideshow below header in web design

I am currently working on enhancing the slideshow feature on my website. If you take a look at the image link provided below, you'll notice that the alignment of the slideshow is slightly off on both sides. Despite my attempts to adjust the CSS width ...

How to use the sha512 hash function in Node.js for Angular2 and Ionic2 applications

I'm attempting to generate a SHA512 Hash in Angular2 (Ionic2) that matches the PHP function hash('sha512'). After trying out different modules like crypto-js, crypto, and js-sha512, I keep getting a different Hash compared to PHP. I even a ...

The main server is not yielding any results from the MongoDB query

I attempted to utilize promises in order to retrieve all the items from my mongoDB database. Here is the code I used: exports.findAll = function(){ return new Promise(function(resolve, reject){ Collection.find({}, function(err, res){ if(err ...