Sticky top header #288
-
Hello, I'm having some issues with the sticky-top class. when I scroll down, the sticks for a little bit, but then it scrolls up anyway.
Is this a recurrent issue or is it just me? any idea how to go around it? thank you |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 7 replies
-
Hello, a sticky element needs the space to be sticky. Check this discussion here #217. To help you out here, please explain what you want to do in detail and of course, a link to your project is always very helpful. |
Beta Was this translation helpful? Give feedback.
-
hi Basti, thank you for your kind reply
https://casinoonlinesoldiveri.it/
if you take a look on my site, there is an image on top the navbar, which has to be there for compliance reasons. when you scroll down, the image correctly disappear and the navbar sticks for a little bit. But if you keep scrolling it also disappears. I'd like for the navbar to stick.
… Il 12/10/2022 09:25 Basti ***@***.***> ha scritto:
Hello,
a sticky element needs the space to be sticky. Check this discussion here #217 #217.
To help you out here, please explain what you want to do in detail and of course, a link to your project is always very helpful.
—
Reply to this email directly, view it on GitHub #288 (comment), or unsubscribe https://github.com/notifications/unsubscribe-auth/AXP2FGFKPLQV4YHJ3HVWKSLWCZRWBANCNFSM6AAAAAARC7UYUY.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
wow, thats great!
weirdly it works from logged into WP, but not from logged out for some reasons, even if I cleaned browser and kinsta cache. Any idea why?
thank you
… Il 12/10/2022 17:09 Basti ***@***.***> ha scritto:
sticky-top won't work there, because header is at same level as content. Means if you reached the part of the site content, element cannot be sticky anymore. That's exactly the same case as described here #217 #217 and that's why header has fixed-top class by default.
In your case I suggest to check if header is on top and add fixed-top class then.
First remove sticky-top class in header.php:
<header id="masthead" class="site-header">
Then add following snippet to your child js/custom.js inside the jQuery(function ($) {...}); wrapper:
var distance = $('#masthead').offset().top,
$window = $(window);
$window.scroll(function () {
if ($window.scrollTop() >= distance) {
$(#masthead').addClass('fixed-top');
} else {
$('#masthead').removeClass('fixed-top');
}
});
Clear browser cache.
Does this help?
—
Reply to this email directly, view it on GitHub #288 (reply in thread), or unsubscribe https://github.com/notifications/unsubscribe-auth/AXP2FGDTKZTIX5GIFJRPAY3WC3ICXANCNFSM6AAAAAARC7UYUY.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Did you add the jQuery snippet? Your |
Beta Was this translation helpful? Give feedback.
-
I did but, and the script works when I am logged into WP. From logged out it doesn't seem be updated.
… Il 12/10/2022 20:39 Basti ***@***.***> ha scritto:
Did you add the jQuery snippet? Your custom.js is empty?
[screenshot] https://user-images.githubusercontent.com/51531217/195422088-3156ea07-90e6-46f7-9305-7784ae3cda1f.png
—
Reply to this email directly, view it on GitHub #288 (comment), or unsubscribe https://github.com/notifications/unsubscribe-auth/AXP2FGFELH4FMV6UKA5A3HLWC4AXDANCNFSM6AAAAAARC7UYUY.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Good morning, I've done it again but it doesn't work from logged out. I guess I will just gave up on it.
One more question about BootScore, is it possible from desktop to swap the search form for the search icon like in mobile? it would be much more elegant
thank you
… Il 13/10/2022 08:15 Basti ***@***.***> ha scritto:
Please add snippet again. Then I can check it as a logged-out user.
—
Reply to this email directly, view it on GitHub #288 (reply in thread), or unsubscribe https://github.com/notifications/unsubscribe-auth/AXP2FGBBQSZQ3IYCUKYBODTWC6SJTANCNFSM6AAAAAARC7UYUY.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
ok thanks,
here is the credentials:
ID: bootscore
PW: xDB4ITuh8#lUKDLkBsymmvrg
https://casinoonlinesoldiveri.it/wp-admin/
… Il 13/10/2022 09:37 Basti ***@***.***> ha scritto:
There is no difference between logged-in and logged-out. What I can say that script isn't there. This can be if you have a caching plugin active which caches for users but not for admins, for example Autoptimize. You can create me an admin account and I will check it again, it should not be a big deal.
>
> One more question about BootScore, is it possible from desktop to swap the search form for the search icon like in mobile? it would be much more elegant
>
Of course, this is possible. But please open a new discussion for this to keep issues organised.
—
Reply to this email directly, view it on GitHub #288 (reply in thread), or unsubscribe https://github.com/notifications/unsubscribe-auth/AXP2FGFRWAB2T2P6YWKO6XTWC633RANCNFSM6AAAAAARC7UYUY.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Ok, this is really strange. As I wrote before, it is a plugin that caches something. But it is not as expected WP Rocket, it is Sucuri Security - Auditing, Malware Scanner and Hardening. Maybe you can try https://wordpress.org/plugins/better-wp-security/ instead. However, you changed code in header.php. I adapted jQuery snippet to this. Now it works for logged-out users, but not for logged-in users. This is because one of plugins mentioned above caches different for users and admins. As logged-in, it's the old code, logged-out the new working one 🤪 So, you have to go through both plugin settings to solve this. |
Beta Was this translation helpful? Give feedback.
-
like this works like a charm!
thank you very much :)
… Il 13/10/2022 10:40 Basti ***@***.***> ha scritto:
Ok, this is really strange. As I wrote before, it is a plugin that caches something. But it is not as expected WP Rocket, it is Sucuri Security - Auditing, Malware Scanner and Hardening. Maybe you can try https://wordpress.org/plugins/better-wp-security/ instead.
However, you changed code in header.php. I adapted jQuery snippet to this. Now it works for logged-out users, but not for logged-in users. This is because one of plugins mentioned above caches different for users and admins. As logged-in, it's the old code, logged-out the new working one 🤪
So, you have to go through both plugin settings to solve this.
—
Reply to this email directly, view it on GitHub #288 (comment), or unsubscribe https://github.com/notifications/unsubscribe-auth/AXP2FGD6QQTJLDXXH3XN3PDWC7DGDANCNFSM6AAAAAARC7UYUY.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thanks very much for all the help! |
Beta Was this translation helpful? Give feedback.
Thanks very much for all the help!