Strange behavior of sticky navigation when scrolling in Safari

I created a unique, single-page website for my parents completely from scratch. I included a sleek navigation menu right below the hero section that sticks to the top of the browser upon scrolling. The functionality is flawless in both Chrome and Firefox.

However, when viewing the site in Safari, I noticed a peculiar issue with the navbar. While the stick-on-scroll feature works fine, everything inside the Navbar seems to re-animate in from the left.

If you'd like to take a look at the website, you can visit it here:

Below are snippets of the jQuery script and CSS code that I used:

var mn = $(".nav");
mns = "nav-fixed";
hdr = $('header').height();

$(window).scroll(function() {
if ($(this).scrollTop() > hdr) {
mn.addClass(mns);
} else {
mn.removeClass(mns);
}
});
.nav {
border-bottom: 2px solid #eee;
position: relative;
background: white;
height: 100px;
margin-bottom: -100px;
box-sizing: border-box;
overflow: hidden;
transition: 0.2s ease-in-out;
}
.nav-fixed {
z-index: 999998;
width: 100%;
max-width: 1440px;
position: fixed;
top: 0;
transition: 0.2s ease-in-out;
-webkit-box-shadow: 0px 6px 10px -5px rgba(0, 0, 0, 0.08);
-moz-box-shadow: 0px 6px 10px -5px rgba(0, 0, 0, 0.08);
box-shadow: 0px 6px 10px -5px rgba(0, 0, 0, 0.08);
}
.nav-fixed:before {
z-index: 999999;
content: '';
display: block;
position: absolute;
width: 150px;
height: 50px;
top: 25px;
left: 25px;
background-image: url('https://dl.dropboxusercontent.com/s/uezydedqpo55ub2/first-fruits-logo-color.svg?raw=1');
background-size: contain;
background-position: center;
background-repeat: no-repeat;
transition: all 0.5s ease-in-out;
}

Your input would be greatly appreciated!

Answer №1

It seems that Safari is experiencing some difficulty with the transition from having no widths declared to declaring both as it becomes fixed. Here's a suggestion to try:

.nav
{
    width: 100%;
    max-width: 1440px;
}

Answer №2

The problem arises due to the introduction of new animatable properties when the .nav-fixed class is applied. More specifically, width and max-width are included. To address this issue, you can include

width: 100%;
max-width: 1440px; 

in the .nav class.

Answer №3

By implementing width: 100% on the .navigation class, the issue disappears completely. It's perplexing why Safari displays such erratic behavior.

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

Validate_checkbox_selection by checking the input ID

Looking at my check_box_tag, it appears like this : check_box_tag('shipping_method[shipping_categories][]', category.id, @shipping_method.shipping_categories.include?(category)) But when I view the output in the browser, it shows as follows : ...

I am experiencing issues with my Vue.js application when trying to send an HTTP POST request

I am encountering an issue in my Vuejs application while trying to send an HTTP POST request to my server. The error message that keeps popping up in the console is: TypeError: _api__WEBPACK_IMPORTED_MODULE_0__.default.post is not a function at Object ...

Trouble in sending email with attachment using Microsoft Graph

I have been working on an application that has the functionality to send emails from a User, following the guidelines provided in this article. Despite everything else functioning correctly, I'm facing an issue when trying to include attachments. The ...

Get the following table row using Selenium when a specific condition is met in the preceding row

Query I am currently working on scraping infoboxes related to French regions from Wikipedia. Specifically, I am interested in extracting the population data for each region. The population information for each region is displayed within the respective in ...

The query for Node.js using mysql is not defined

Recently, I've been working with Node.js and attempting to incorporate mysql in conjunction with nodejs. Specifically, I have written a query trying to retrieve numbers from a table: select numbers from TABLE, but the end result shows up as: "undef ...

Struggling with eliminating the # from a URL in AngularJS

I am working on a single-page application built with AngularJS. The URL structure I currently have looks something like this: .../Angular/index.html. However, when I click on a link within the page, the URL transforms to .../Angular/index.html#/addStudent. ...

Guide on exporting a function from Node.js and utilizing it as middleware

Within my middleware directory, there is a file named auth.js. This file contains the following function: function authCheck() { if (req.session.loggedin) { return; } else { req.session.destory(); res.redirect('/login'); } } I ...

Transforming HTML 'img' elements into React components without losing styling: How do I achieve this with html-to-react?

I am seeking guidance regarding the usage of the html-to-react library. Consider the following html string: '<div> <img src="test.png" style="width: 100px;"/> <img src="test2.png" style="margin: 0px 4px;"/> </div>' ...

Access-Control-Allow-Headers does not allow the use of X-Requested-With

I'm currently working on a system that includes an add item to cart feature. This functionality involves using Jquery's $.ajax method. However, I've encountered an error when attempting to access the online server - "XMLHttpRequest canno ...

What is the best way to utilize the useSWR hook when there are necessary logical operations to be performed on the response before proceeding with the next API call

I am currently utilizing the swr library in a Create React App and require the usage of the useSWR hook for data fetching that is both contingent and conditional. The specific task at hand involves: Making an API call to retrieve an id which will be used ...

Is it possible to include an if or else condition in jQuery JSON response?

I have an issue with adding my Jquery JSON response to a data table. However, I need to implement if conditions based on the day. Can you provide me with an example of how to do this? Specifically, I need to use conditions in the data.hours.day field. Th ...

Utilize CSS to automatically reposition the left and right divs under the center div, creating a seamless layout

When styling divs inline, they will automatically wrap to the next line if they don't fit in the viewing window. This is often used for creating a quick and simple mobile version of a website. I am interested in achieving this effect with both sides ...

How can I enable form submission in jQuery while overriding the preventDefault function?

I created a function to validate that at least one form field is filled out: function checkFields(form) { var checks_radios = form.find(':checkbox, :radio'), inputs = form.find(':input').not(checks_radios).not('[ty ...

What Causes the Highlight Menu Item to Not Function in ASP.NET MVC?

Why is the Highlight Menu Item Not Working in ASP.NET MVC? I've been experimenting with a method to highlight the selected menu item in an MVC program. The test environment consists of: 1) ASP.NET Core with MVC (using .NET 5) 2) Bootstrap V4.6 Firs ...

Tips for transferring information between two HTML pages

Looking for some advice here. I'm in the process of creating a website for my record store using HTML5. On one page (store.html), I plan to showcase all the albums with a Buy Now button below each album that links to buy.html <div class="item got ...

Is it not possible to generate HTML tags using jQuery and JavaScript in JSF?

I'm currently working with jsf 2.0 and richfaces 4.0 to develop my application. Occasionally, I incorporate jQuery and JavaScript functions for displaying and hiding elements. However, I've encountered an issue when trying to generate tags within ...

Having trouble getting an element by id in Vue/Nuxt on initial load? You're not alone. It seems like the element

I am currently utilizing VueScroll as a container for a carousel. However, I have observed that when a user hovers their mouse over the VueScroll element and scrolls using the wheel, it zooms in/out on the elements inside VueScroll. I am looking to target ...

What reasons could lead to useSWR returning undefined even when fallbackData is provided?

In my Next.js application, I'm utilizing useSWR to fetch data on the client-side from an external API based on a specified language query parameter. To ensure the page loads initially, I retrieve data in a default language in getStaticProps and set it ...

The functionality of Angular/Typescript class.name appears to fail during a production build

Using Angular 5, I encountered an unusual problem with the class.name property. We have a TypeScript function as shown below: export class ApiService { public list<T>(c: new(values: Object)=> T) { var cname = c.name; .... } } When ...

Splitting the Django REST backend from the front end

I've been researching for hours, but I still can't find the information I need. This is a different kind of question. My Django REST backend is set up with a very simple REST API that includes only one Model: Model.py from django.db import mode ...