Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Bedford- Sticky header change opacity or color as page is scrolled


Peakwalker

Question

Site URL: http://www.peakwalkerpdx.com

Hi I currently have CSS installed on my page so that when scrolled through, the header follows along stuck at the top of the browser window. I would like for the header background color to be transparent over a banner image and then increase in opacity once it is scrolled past the banner image. Can anyone share coding to do this?

This is the CSS currently installed to make the banner sticky and fix the overlap onto the main page:

header#header {
position: fixed !important;
left: 0;
right: 0;
top: 0;
z-index: 999;
}
main#page {
margin-top: 80px;
}
Edited by Peakwalker
Link to comment

1 answer to this question

Recommended Posts

  • 0
1 hour ago, Peakwalker said:

Site URL: http://www.peakwalkerpdx.com

Hi I currently have CSS installed on my page so that when scrolled through, the header follows along stuck at the top of the browser window. I would like for the header background color to be transparent over a banner image and then increase in opacity once it is scrolled past the banner image. Can anyone share coding to do this?

This is the CSS currently installed to make the banner sticky and fix the overlap onto the main page:

header#header {
position: fixed !important;
left: 0;
right: 0;
top: 0;
z-index: 999;
}
main#page {
margin-top: 80px;
}

Add this into page code injection to enable a scroll-wise animation

<script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js"></script>
<style>
#header {
  transition: all 0.5s;
}
.header-transparent{
  background-color: transparent !important;
}
</style>
<script>
  document.addEventListener('DOMContentLoaded', function() {
      var controller = new ScrollMagic.Controller();
      var myScene = new ScrollMagic.Scene().addTo(controller);
      var scene = new ScrollMagic.Scene({
              triggerElement: "#block-yui_3_17_2_1_1563832386099_11359",
              triggerHook: 0,
              duration: document.querySelector("#block-yui_3_17_2_1_1563832386099_11359").clientHeight
          })
            .setClassToggle('#header', 'header-transparent')
            .reverse(true)
            .addTo(controller);
});
</script>

the text "#block-yui_3_17_2_1_1563832386099_11359" is unique id of the block you want the the header transparent, find it using: Squarespace ID Finder - Chrome Web Store (google.com)

image.thumb.png.478811b0871f88ea9d0e6aa3c1d06439.png

Greeting, it's BaNgan from BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Portfolio hover Replace Link Style
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...