All things Shopify and commerce
Hi,
How do I make my logo transparent when scrolling and it is above an image and/or text.
See example website: https://uptherestore.com/
URL is not on hand as of yet - sorry!
Hi @RhyMol ,
You can try adding the following event listener for the logo element to make it transparent on the scroll.
You can go to your Shopify admin panel.
Click on Online Store > Themes.
Click on Actions > Edit code.
Locate the file named theme.liquid (that controls the overall layout)
Paste the following scroll effect snippet before closing the </body> tag:
(you might need to adjust this selector depending on your theme's structure, please see the attached screenshot and explanation below to identify your theme's logo element)
window.addEventListener('scroll', function() {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop;
let logoElement = document.querySelector('.header-logo'); // Adjust selector if needed (see explanation below)
if (scrollTop > 0) {
logoElement.style.opacity = 0; // Make logo transparent on scroll
} else {
logoElement.style.opacity = 1; // Make logo solid on top
}
});
Explanation:
1. When scrolling, this code adds a scroll event listener to the logo element ('header-logo' in this example) and you might need to adjust this selector depending on your theme's structure. Based on the scroll position, makes the logo transparent and solid.
2. You can also change the logo's transparent initiate position by adjusting the 'if' condition value ('scrollTop > 0' in this example).
3. Find your Logo element classname or identifier: Right-click on your website logo > Click 'Inspect' > Identify the logo class (see the attached sample screenshot) inside the 'Header' open(<Header>) and closing(</Header>) tags.
Please reach out if you need further assistance.
I hope this helps! If it does, please like it and mark it as a solution!
Regards,
Sweans
Hi @RhyMol ,
We are providing an update to the code for better understanding.
window.addEventListener('scroll', function() {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop;
let logoElement = document.querySelector('.header-logo'); // Adjust selector if needed (see explanation below)
if (scrollTop > 0) {
logoElement.style.opacity = 0.5; // Make logo transparent on scroll here. You can adjust the value from 0.1 to 0.9 according to your requirement.
} else {
logoElement.style.opacity = 1; // Make logo solid on top
}
});
Hi @RhyMol
You can try to add this code to Custom CSS in Online Store > Themes > Customize > Theme settings and check if it reaches your request
.scrolled .header .header__logo { opacity: .3; }
- Helpful? Like and Accept solution! Support me: Buy coffee
- Ryviu - Reviews & QA app, collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy app: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024Note: Customizing your CSS requires some familiarity with CSS and HTML. Before you cust...
By JasonH Aug 12, 2024