-
Anonymous
Hello,
I’m having an issue with my nav bar “<nav>” changing from position fixed to position absolute, when scrolling for mobile.
I’ve double checked my child theme CSS and I haven’t modified the positioning for mobile.
I can’t tell if this is some Javascript that is modifying the CSS?You can recreate this if you make your browser window small/mobile sized and scroll downwards on the home page (provided below). After scrolling about half way down the page, the Nav bar stops being in a fixed position.
Any advice would be much appreciated? ๐
Kind regards
Daniel -
Hi there,
I can not see or log in to your site as it’s under maintenance, and the WP login page doesn’t show.
https://app.screencast.com/NvzOnbGfW2UD3 -
Anonymous
Apologies – does it work through https://anielapiasecka.site/wp-admin/
-
Alvind
Hi there,
Try adding this CSS:
nav.is_stuck { position: fixed !important; top: 0 !important; }
-
Anonymous
Amazing thanks, that worked ๐
-
Anonymous
Amazing thanks, that worked ๐
-
Anonymous
Hi Alvind
Apologies this has partially fixed the problem.I’ve noticed since implementing this, Nav bar works well, however on a page refresh the nav bar still fluctuates between CSS values. (It’s easiest to recreate in mobile views and scroll down). When I look at the dev console I can see NAV changes CSS attributes based on scroll position (Both absolute and top positioning). By default I would like to have the positioning set to fixed/sticky from the start.
You can also notice this just by seeing the main container (.site .grid-container) jumps behind the NAV bar on a page refresh initially. I’m not sure if this is a generatepress stylesheet thing or a third party JS script causing this?
Here’s the CSS I’ve added
/*
* Fixes Nav glitch switching from absolute to fixed
*/
nav.is_stuck {
position: fixed !important;
top: 0 !important;
}
nav {
position: fixed !important;
top: 0 !important;
width:100% !important
}Any advice would be much appreciated, thanks again ๐
Daniel -
Hi there,
The CSS changes are due to the mobile menu changing while scrolling. Are you using a plugin or custom JS to achieve that?
If so, the plugin or JS is changing the CSS. If you can find the source and change the CSS there, it should fix the problem.
However, I don’t think the CSS change matters. There are no visual differences between the 2 positions. Nothing needs to be fixed in your case.
-
Anonymous
Morning! Thanks for checking Ying ๐
I’ve checked plugins and there’s nothing causing this change.
I’m only using the Primary Menu with CSS breakpoints for mobile, and I haven’t changed the positioning to cause it to momentarily switch to absolute. The Secondary and Mobile Menus are all disabled and I checked the customize tab too.
Also I checked another website I built using GeneratePress and it has the exact same issue, but it doesn’t show visually.
With Alvind’s CSS amendments it’s looking good.
And as you say in this case it’s not causing any visual interference with a page refresh just now and hopefully with litespeed cache, that will smooth over any HTML elements jumping around in the future…
Unless you spot anything else I’ll close the thread.
Thanks
Daniel -
You are welcome Danielย ๐
- You must be logged in to reply to this topic.