saeppi Posted May 3 Share Posted May 3 Hey guys, I would like to have my navigation bar (header) change colour on a scroll. I found below .js snippet listening to such an event. I only seem to be able to apply changes to the background colour of the bar and the font colour of the links. I would like to also have my logo and the shopping cart change colours. Any ideas what I need to insert in addition to below? Thanks! CSS #header { background-color: rgba(0,0,0,0); transition: background-color 500ms ease; &.is-scrolled { background-color: white; } } header#header.shrink a { transition: color 500ms ease; color: black; } JavaScript <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript"> $(window).on("scroll",function(){ var header = $("#header"); if ($(window).scrollTop() >= 100) { header.addClass("is-scrolled"); } else { header.removeClass("is-scrolled"); } }); </script> Link to comment
saeppi Posted May 4 Author Share Posted May 4 https://bagpipe-bat-sayc.squarespace.com PW: aqi2024 Link to comment
Solution Sam0smith Posted May 4 Solution Share Posted May 4 Please add this css on your website : Let me know how it goes. .is-scrolled a { color: #000 !important; } .is-scrolled .icon.icon--cart { stroke: #000 !important; } .is-scrolled .icon-cart-quantity { stroke: #000 !important; } niko-rahayo81 and DavidStewart 2 Link to comment
saeppi Posted May 4 Author Share Posted May 4 (edited) Awesome thanks @Sam0smith ! How would I apply these injections for only the main page? Edited May 4 by saeppi Link to comment
Sam0smith Posted May 5 Share Posted May 5 In order to target a specific page, you just have to go to the “Website” tab in the Squarespace editor. Once you do that, hover on the page that you’re targetting then click the settings icon of that specific page. Once you do that, click the advanced tab and paste the following CSS code there: <style> .is-scrolled a { color: #000 !important; } .is-scrolled .icon.icon--cart { stroke: #000 !important; } .is-scrolled .icon-cart-quantity { stroke: #000 !important; } </style> Link to comment
saeppi Posted May 5 Author Share Posted May 5 Thanks, I figured I will only be able to "overwrite" the main code in the advanced tabs of the single pages. I was hoping I don't need to touch the other pages and just make the index page dynamic. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment