hello!
Wondering if someone can help me im wanting to make my header transparent and then turn to the solid colour when i scroll.
Is this possible?
A user seeks to create a transparent header that becomes solid when scrolling past an image on the Dawn theme.
Solutions Provided:
Multiple respondents offer similar approaches:
Technical Implementation:
The solution involves:
theme.scss.liquid to add CSS for transparent header with rgba(0,0,0,0) and transition propertiesCurrent Status:
The original poster asks a follow-up question about where to place the JavaScript code, indicating the discussion remains open with implementation details still being clarified.
hello!
Wondering if someone can help me im wanting to make my header transparent and then turn to the solid colour when i scroll.
Is this possible?
Hi @Andia
First of all have to add a class for header on scroll.
Then have to write the css accordingly.
this can be done usning the custom css and js code.
Hello @Andia ,
You can try to follow these steps:
Go to Online Store → Themes → Actions → Edit code
Go to theme.scss.liquid file → Add this following code at the bottom of page
.site-header {
background-color: rgba(0, 0, 0, 0);
transition: background-color 0.3s ease;
}
Add this Javascript code
$(document).ready(function() {
var header = $(".site-header");
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll > 100) {
header.css("background-color", "your-solid-color-hex-code");
} else {
header.css("background-color", "rgba(0, 0, 0, 0)");
}
});
});
Save and preview
Hope this can help.
Ali Reviews team.
where does the javascript go??