-
AuthorPosts
-
October 8, 2018 at 3:18 pm #1018999
Hi, i would like my header to change colour when you start to scroll, have you got code for this?
October 8, 2018 at 7:14 pm #1019142Hey timchurchman,
Please provide a link to the site page in question so we can look into this issue further.
Best regards,
Jordan ShannonOctober 10, 2018 at 6:13 pm #1020029October 11, 2018 at 4:58 pm #1020370Hi,
Once you scroll down you want it a different color?
Best regards,
Jordan ShannonOctober 11, 2018 at 6:28 pm #1020432Hi, yes as I start to scroll down the page the color changes?
October 14, 2018 at 3:11 pm #1021213Hi,
To change the header background color on page scroll, please enable shrinking header from Enfold > Header > Header Behavior
And use the below CSS
#top #header.header-scrolled .container.av-logo-container { background: gold; }
Best regards,
VinayOctober 14, 2018 at 8:06 pm #1021279Unfortunately never worked, any other suggestions? Added my logins if you need to look?
October 15, 2018 at 6:01 am #1021388Hi,
The CSS Merging was enabled in Enfold > Performance tab. This will cache the CSS files so you were not able to view the changes. Whenever you add any CSS or JS please disable this option and refresh the page a few times to view changes.
I also adjusted the code to below :
#top #header.header-scrolled #header_main { background: #88bbc8; }
Best regards,
VinayOctober 18, 2018 at 10:29 pm #1023689Thank you!
October 19, 2018 at 5:01 pm #1024036Hi,
Did you need additional help, or shall we close this topic?
Best regards,
Jordan ShannonJanuary 11, 2020 at 1:53 pm #1172379Hi,
Is it possible to change the header color, without having to activate the shrinking header?
Best regards,
SebastianJanuary 11, 2020 at 11:25 pm #1172463Hi,
So you want it a single color at all times? If it’s only when scrolling then attaching it to the shrinking class is the most sensible way of doing it.
Best regards,
Jordan ShannonJanuary 11, 2020 at 11:40 pm #1172471Hi,
Thanks for your quick answer.
I want it to change its color once when i scroll down the page up to a certain point.
I’ll give you a page where I saw it in the private content.
It should not be shrinking at all if possible. And the text of the menu should change its color as well if that’s possible, too.January 14, 2020 at 11:13 am #1173218Hi,
Thank you for the update.
Is it possible to change the header color, without having to activate the shrinking header?
The required class attribute header-scrolled is only available when the shrink option is enabled and the css modifications above will not work without this attribute, so it has to be enabled. You can always use css to prevent the header from shrinking even if the option is enabled.
Now, if you want the header to only change after scrolling down up to a certain point or position, then you have to modify the enfold\js\avia-snippet-sticky-header.js. Add another condition in the else statement.
if(st - 30 < el_height) { av_change_class(header, 'remove', 'header-scrolled-full'); } else { av_change_class(header, 'add', 'header-scrolled-full'); }
Best regards,
IsmaelJanuary 14, 2020 at 12:20 pm #1173246Okay, thank you for the tips. Unfortunately my programming skills aren’t good enough to do so, but maybe some day the will be!
Thanks a lot!January 14, 2020 at 4:05 pm #1173409Hey,
You are welcome!
Please let us know if you need further assistance on this case :)Regards,
YigitApril 23, 2023 at 6:20 am #1405270I tried both of these on my site and neither changed the color when scrolling down?
#top #header.header-scrolled .container.av-logo-container {
background: gold;}#top #header.header-scrolled #header_main {
background: #88bbc8;}April 23, 2023 at 7:48 pm #1405300Hi,
Please note that these will only work if your header is set to Enfold Theme Options ▸ Header ▸ Header behavior ▸ Shrinking Header this is the only time that the class header-scrolled is added.
I tested the css and it works, if it is not working for you and you are using the Shrinking Header option then please open a new thread with an admin login so we can be of more assistance, since this is not your thread posting your login here will not be private and you will not see anything we write in the Private Content area.Best regards,
MikeApril 23, 2023 at 9:04 pm #1405308with the new enfold – you can set the shrink amount to 10% – maybe Günter will be persuaded to include the 1% mark in the list there. In that case, a reduction would be hardly noticeable, and the classes would then be set anyway.
btw. i’m not willing to check pages that are not secured bei SSL ( TLS ) ;)
or leave the header as it is- no shrink and set your own scroll event on the header
this to child-theme functions.php:
you had to set in this calculation the rgb values!function bg_color_on_scroll(){ ?> <script> window.addEventListener("DOMContentLoaded", function () { (function($){ var tStart = 30, // Start transition at 30px from top tEnd = 250, // End at 250px cStart = [255, 255, 255], // White cEnd = [255, 215, 0], // Gold cDiff = [cEnd[0] - cStart[0], cEnd[1] - cStart[1], cEnd[2] - cStart[2]]; $(".header_color .header_bg").css('background-color', 'rgb('+cStart+')'); // take over the start point $(document).scroll(function() { var p = ($(this).scrollTop() - tStart) / (tEnd - tStart); // % of transition p = Math.min(1, Math.max(0, p)); // Clamp to [0, 1] var cBg = [Math.round(cStart[0] + cDiff[0] * p), Math.round(cStart[1] + cDiff[1] * p), Math.round(cStart[2] + cDiff[2] * p)]; $(".header_color .header_bg").css('background-color', 'rgb(' + cBg.join(',') +')'); }); })(jQuery); }); </script> <?php } add_action('wp_footer', 'bg_color_on_scroll');
you see the parameters you can change? – the var values
and the selector ( .header_color .header_bg ) on the bottom might differ to yours – as mentioned above your page is not https.April 24, 2023 at 7:42 pm #1405436Thank you
-
AuthorPosts
- You must be logged in to reply to this topic.