The Bootstrap Mobile Navigation transition is not displaying as intended in my CSS coding

On both desktop and mobile screen sizes, I have a white navigation bar. However, for the mobile dropdown menu, I want the background to be grey.

I managed to achieve this by targeting .show on smaller screens in the CSS and specifying the grey background color.

But when toggling the navigation button to open the menu, there is a transition glitch where it displays a white background initially before transitioning to the correct styling that I set.

I am wondering if the solution lies within CSS3's ::before or ::after pseudo-elements.

Any suggestions or ideas?

HTML

<!-- Navigation -->
<nav class="navbar navbar-expand-lg fixed-top">

  <img class="navlogo img-fluid" src="img/master/logo1.jpg"> 

<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
  aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation" style="
  margin-right: 12px;">
  <span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse justify-content-end" id="navbarNav">
  <ul class="navbar-nav">

      <li class="nav-item active">
          <a class="nav-link" href="Default.html"><u>Home</u></a>
      </li>
      
    <li class="nav-item">
          <a class="nav-link" href="services.html"><u>Services</u></a>
      </li>
</nav>

CSS

 @media (min-width:345px) and (max-width: 379px) { 
    .navbar .show  {background-color: #f5f5f5; padding:10px; border-bottom:solid 1px black; border-radius: 5px;}    
  }

During Transition (white background, no padding-left)

After Transition (grey background, padding-left applied)

Answer №1

Austin bootstrap has its own unique set of components, and the CSS animation mentioned will only occur once it has completed as previously stated. To address this issue, you must apply the same properties in CSS to the 'collapse' element.

<div class="collapse" id="navbarToggleExternalContent" style=" background-color: #f5f5f5; border-bottom:solid 1px black; padding:10px;">

I would advise against directly applying style properties for this as it may temporarily override the wrapper. However, as a short-term solution, it can work well. Another option is to customize the 'collapse' using Bootstrap's properties, which I suggest exploring when you have the chance.

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

Loading bar for AngularJS material framework

Is there a way to integrate https://material.angularjs.org/latest/demo/progressLinear into my website so that it shows progress when a new view is loading? I'm trying to figure out how to obtain the value of the current page being loaded. Any suggest ...

The combination of Spring Boot and Angular's routeProvider is a powerful

I have been working on a project using Spring Boot, REST, and AngularJS. While I successfully implemented the back end with REST, this is my first time using AngularJS. Despite watching numerous tutorials and following them step by step, I am still facing ...

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 ...

Is there a way to retrieve the disabled drop-down field value after submitting the form?

I'm struggling with a dropdown field that becomes disabled once an item is selected. After submitting the form, the dropdown field loses its value and I'm left with an empty field. Any suggestions on how to keep a value in the dropdown after subm ...

Submitting data twice through AJAX POST requests

Using a PHP file called via AJAX to insert data into MySQL. Prior to the insert statement, the PHP code runs a select query to check for duplicate records and then proceeds with the insert statement. Problem: When calling the PHP file from AJAX, it gets ...

What is the process for extracting context or span from an incoming http request in NodeJS without relying on automated tools

I am currently in the process of transitioning my Node.js application from using jaeger-client to @opentelemetry/* packages. Within my Node.js application, I have a basic http server and I aim to generate a span for each response. Previously, with jaeger ...

Can XMLHttpRequest be exploited for XSS attacks?

Can cross-site scripting be achieved using an XMLHttpRequest as a post method? For instance, in a chatroom where users can enter text. Normally, inserting scripts like <script>alert("test")</script> would be blocked. However, you could write a ...

Arranging nested arrays

There is a nested list provided with the following markup (which cannot be altered currently). My goal is to sort this list and all nested lists by the title of the 'a' tag. The initial div (not nested in 'li') should be used for sortin ...

Experience the power of Kendo UI Date Picker combined with AngularJS. When the datepicker is initialized, it starts

Check out my code snippet below: When the datepicker loads initially, it appears empty. However, if you remove ng-model from the directive template, the datepicker displays its initial value correctly. Yet, changing the selected date does not mark the fo ...

`Next.js project experiencing issues with scroll trigger functionality`

I've been working on a gsap animation with a scroll trigger, and while the animation itself functions fine, it's not triggering as expected. The AnimationEffect code involves using gsap and scrolltrigger to create the animation. The Hero section ...

What is the correct way to implement ::v-deep(<inner-selector>) in a Vue component?

I am attempting to assign an existing style class to a child element that will be loaded using the v-html directive. Since /deep/ and >>> are no longer supported, I have tried using ::v-deep in Vue. <template> <div v-else v-html="chi ...

React component encountering unexpected prop value

In my project, I have a Modal component and a Form component. The Modal is a functional component, while the Form is a class component responsible for handling form submissions. The Modal component passes all of its props to the Form component. Within Mod ...

Bug in Chrome causing issues with autofilling fields in AngularJS applications

Seeking a solution to address a bug noticed while utilizing a custom Angular directive in conjunction with Chrome's autofill feature. The directive is designed for a phone number field, automatically adding dashes "-" to enhance user experience by eli ...

Integrating a fresh element into the carousel structure will automatically generate a new row within Angular

I'm currently working on an Angular4 application that features a carousel displaying products, their names, and prices. At the moment, there are 6 products organized into two rows of 3 each. The carousel includes buttons to navigate left or right to d ...

Verify two asynchronous boolean variables and trigger a function if both conditions are met

Is there a way to enhance the rendering process so that the renderFilters() method is only called when both variables are true: These two variables are loaded asynchronously through 2 API methods: //getManager() this.isLoadingManager = true; //getPdiPOrg ...

Learn how to retrieve information using the dash operator in ReactJS

I find it a bit amusing, but I'm encountering an issue. Can anyone lend me a hand with this? So, I'm using an API to fetch some data and it appears that the response from the API is in this format: start-time:2323232 end-time:2332323 Now, when I ...

When you hover over an image, its opacity will change and text will overlay

I am looking for a way to decrease the opacity and overlay text on a thumbnail image when it is hovered over. I have considered a few methods, but I am concerned that they may not be efficient or elegant. Creating a duplicated image in Photoshop with the ...

New Relic identifies mysterious delays caused by MongoDB's findOne method

After setting up newrelic to pinpoint the bottlenecks in my app, I discovered a major issue that has left me stumped. The source of most delays seems to be mongoDB user.findOne, but the biggest challenge is locating where in the code this delay is occurri ...

Having trouble with installing a React app using npx create-react-app my-app?

description needed for image Having trouble creating a react application using npx create-react-app my-app... Encountering errors shown in the image. Attempted npm init but it was unsuccessful. Included node.js and vs code in the path. ...

Issue with authentication when accessing Google Video API

I'm attempting to utilize the Google API provided: I have downloaded the Sample Project and followed these steps: 1) Navigate to the Project Folder named API Video 2) Run npm install 3) Set GCLOUD_PROJECT = neorisvideo 4) Download Json from the C ...