Each time I load the page, it displays differently depending on the browser. I'm struggling to understand the reason

Trying to figure out how to make the navigation bar close when a link is clicked and directed to a section instead of a new page. When on a large screen, I want the nav bar to remain open but automatically close when on a small screen (for example, when the "NextEvent" link is pressed). Any ideas?


    <body>
      <nav>
        <header class="header d-flex align-items-center container-fluid">
          <div class="row align-items-center flex-grow-1">
            <div class="col-auto">
              <div class="logo">
                <h4>thomas<br> venutu</h4>
              </div>
            </div>
            <ul class="nav-links ">
              <li><a href="#section2">Home</a> </li>
              <li><a href="#section2">NextEvent</a> </li>
              <li><a href="index">Music </a> </li>
              <li><a href="index">About</a> </li>
              <li><a href="index">Boooking</a> </li>
            </ul>
            <div class="burger">
              <div class="line2"></div>
              <div class="line1"></div>
              <div class="line3"></div>
            </div>
          </div>
        </header>
      </nav>
    

    #
    html {
      scroll-behavior: smooth;
    }

    #extra space {
      -webkit-box-sizing: border-box;
      -moz-box-sizing: border-box;
      box-sizing: border-box;
    }
    ...
    

JavaScript


    const navSlide = () => {
      const burger = document.querySelector('.burger');
      const nav = document.querySelector('.nav-links');
      const navLinks = document.querySelectorAll('.nav-links li');

      burger.addEventListener('click', () => {
        nav.classList.toggle('nav-active');
      });

      navLinks.forEach((link, index) => {
        link.style.animation = `navLinkFade 0.5s ease forwards ${index / 7}s`;
        console.log(index / 7);
        nav.classList.toggle('nav-disable');
      });

      navLinks.addEventListener('click', () => {
        nav.classList.toggle('nav-active');
      });
    }
    navSlide();
    

Need Fix


    navLinks.addEventListener('click', () => {
      nav.classList.toggle('nav-active');
    });
  

Answer №1

It is important to note that Internet Explorer may not properly interpret media queries, so it is advisable to use conventional methods to prevent any issues. Additionally, the order in which media queries are written can also affect their functionality.

There could be multiple reasons for this issue.

One solution is to rearrange the code and move all content inside certain media queries to the top of the stylesheet. For example:

// General styles for all devices (desktop and mobile) go here
html{...

// Styles for larger screens such as tablets in vertical orientation
@media only screen and (max-width: 900px) {
}

// Styles for smaller screens like smartphones
@media only screen and (max-width: 600px) {
}
...

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

"Safari (iOS) is experiencing a functionality issue where Alert() is working, but console.log() is

Just a heads up before you dive in: I've encountered an issue with Safari related to Chrome, but it seems to work fine on other browsers. So, it could be more OS-specific rather than a general problem. I recently ran into a frustrating situation whil ...

Issue with Angular ngModel not syncing with variable changes

Currently using Angular 4 and Typescript, I have a table containing <select> elements in my template: <tr *ngFor="let task of tasksDetails"> <td>{{task.name}}</td> <td> <select class="form-control" [(ngMode ...

Experiencing trouble with detecting intersections using the Three.js raycaster

After successfully writing a code to intersect some objects, I encountered an issue when adding a canvas along with other div elements in the HTML document. Now, there seems to be no intersection on the object. You can observe this live example here. If yo ...

What could be causing my SVG bezier curves to malfunction in Firefox?

Encountered an issue today where diagrams I have generated are not functioning properly in Firefox when created using the getPointAtLength method. Here is a demonstration of the problem: http://jsfiddle.net/xfpDA/9/ Please take note of the comments at th ...

When calling `getAuth()`, an object is returned. However, upon reloading the page, the

My code is extensive, so I have only included a portion that I believe is crucial. import {getAuth} from "firebase/auth" const authFirebase = getAuth() console.log(authFirebase) const Home = () => { ... return( ... ) } Every time I ...

Utilizing Vue.js and i18n to fetch external JSON files from a server and seamlessly integrating them as globally accessible data in all components

I'm currently exploring ways to fetch translation files from a server and make them accessible across all components of the project. For instance, I can request to obtain this JSON: { "DASHBOARD_SETTINGS": "Einstellungen", ...

Error encountered when generating bower.json due to absence of version number

After generating the bower.json file, I noticed that the version number was not included in the information collected. The current content is as follows: { "Name": "conFusion", "Authors": [ "Aurora" ], ... } Although the version n ...

A step-by-step guide on creating a unique ticket number sequence in PHP

Looking to create a unique ticket number sequence using PHP? Here's the given sequence: 1-W1 (mandatory). 2-Date (yy-dd-mm) format. 3-001-999 (resets daily from 001). Check out this example: e.g. - W120200101001 I've started the code below, b ...

Issue with JQM popup functionality in Firefox browser

I am currently utilizing JQM 1.3.1 and have a webpage featuring various popups located at the bottom of the page: <div data-role="page" data-title="Strategic Plans"> <div data-role="content" id="capbPlans" data-bind="cafeLiveScroll: { callbac ...

What is the best way to send an array element to a function?

In my PHP code, I am fetching data from a database and encoding it in JSON to be called by an AJAX request. while ($row = mysqli_fetch_assoc($empRecords)) { $data[] = array( "level"=>$whatTeam($row['level&a ...

In HTML 5, you can use either #Header or the <header> tag

I'm feeling a bit puzzled about html right now, so I have a question regarding the use of semantic elements: Should I structure my code like this? <html> <head> <title>Some page</title> </head> <body> < ...

Can you explain how differential inheritance works in JavaScript?

This response to a question about the Object.create() method in JavaScript on SO discusses the concept of differential inheritance. The explanation given is as follows: This particular technique enables you to easily establish differential inheritance, ...

Proceed to the section with modal

My goal is to create a modal with 4 sections, each loading its content dynamically using the .load() function to the container on the right side. The challenge I'm facing is that I have a footer menu that triggers the modal to open, and I need it to ...

Retrieving dropdown options with the help of selenium and node.js

I'm looking to gather all the options from a dropdown menu and loop through them to submit a form. I need the list of values from the dropdown. The following Java code meets my requirements perfectly, but I am in need of the same functionality in Jav ...

Extract data from a JSON object and connect it to input fields on a form

I am currently working with a large JSON object that I need to parse and bind to various form fields. Here is a snippet of the code, but you can view the entire code here. The main question I have is what would be the most efficient way to achieve this? Wo ...

Transferring data between two HTML files through the POST method

Is there a way to pass two values (parameters) from one HTML page to another without displaying them in the URL, similar to using the POST method? How can I retrieve these values on the second HTML page using JavaScript, AJAX, or jQuery? For example: cli ...

Displaying threaded discussions in React

Below is an array that contains comments, and I am attempting to display them in a threaded manner by utilizing the parentId property. comments: [ { id: 1, parentId: null }, { id: 2, parentId: 1 }, { id: 3 ...

Database query not appearing on node.js route

As a newcomer to javascript and nodejs, I have encountered an issue that I'm hoping to get some clarification on. I am currently working on a simple API and facing difficulties in understanding why a certain behavior is occurring in my code. app.get( ...

"Discover the step-by-step process of transforming an input field value into a checkbox with

I've been experimenting with creating a To-Do list using HTML, CSS, and Javascript. I've managed to capture the input field value in a fieldset so far. However, my goal is to find a way to transform the input field value from the textfield into a ...

Adapting the position of a table row in AngularJS based on the

I need assistance with creating a dynamic table-row that moves to indicate the current time in a table filled with timestamps. <table> <tr ng-repeat="timestamp in timestampArray"> <td>{{timestamp}}</td> </tr> ...