Shopify themes, liquid, logos, and UX
Hi,
I need help with adding code including appearing menu on hover on desktop. Specifically mega menu. I would be grateful for help
Solved! Go to the solution
This is an accepted solution.
@Aleksander22 , follow these step
Step 1. Go to Admin -> Online store -> Theme > Edit code
Step 2. Find the file theme.liquid.
Step 3. Add this code above </body>
<script>
document.addEventListener("DOMContentLoaded", (event) => {
let items = document.querySelector(".header__inline-menu").querySelectorAll("details");
items.forEach(item => {
item.addEventListener("mouseover", () => {
item.setAttribute("open", true);
item.querySelector("ul").addEventListener("mouseleave", () => {
item.removeAttribute("open");
});
item.addEventListener("mouseleave", () => {
item.removeAttribute("open");
});
});
});
});
</script>
Step 4: Find the file base.css and add this code to the end
header-menu [open] summary:after {
content: "";
position: absolute;
height: 2em;
top: 3em;
left: -2em;
right: -2em;
}
Hope it helps 😊
B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.
B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.
B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.
BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now
This is an accepted solution.
@Aleksander22, change the previous code in theme.liquid file like this
<script>
document.addEventListener("DOMContentLoaded", (event) => {
let items = document.querySelector(".header__inline-menu").querySelectorAll("details");
items.forEach(item => {
item.addEventListener("mouseover", () => {
item.setAttribute("open", true);
item.querySelector("ul").addEventListener("mouseleave", () => {
item.removeAttribute("open");
});
item.addEventListener("mouseleave", () => {
item.removeAttribute("open");
});
});
});
const listItems = document.querySelectorAll('.list-menu');
const mainContent = document.getElementById('MainContent');
listItems.forEach(item => {
item.addEventListener('mouseenter', () => {
mainContent.style.filter = 'blur(4px)';
});
item.addEventListener('mouseleave', () => {
mainContent.style.filter = 'none';
});
});
});
</script>
Result:
B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.
B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.
B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.
BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now
Can you describe the problem you're having more clearly?
If our suggestions are useful, please let us know by giving it a like or marking it as a solution.
Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)
Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page
Thanks for your support the other guy already help me
This is an accepted solution.
@Aleksander22 , follow these step
Step 1. Go to Admin -> Online store -> Theme > Edit code
Step 2. Find the file theme.liquid.
Step 3. Add this code above </body>
<script>
document.addEventListener("DOMContentLoaded", (event) => {
let items = document.querySelector(".header__inline-menu").querySelectorAll("details");
items.forEach(item => {
item.addEventListener("mouseover", () => {
item.setAttribute("open", true);
item.querySelector("ul").addEventListener("mouseleave", () => {
item.removeAttribute("open");
});
item.addEventListener("mouseleave", () => {
item.removeAttribute("open");
});
});
});
});
</script>
Step 4: Find the file base.css and add this code to the end
header-menu [open] summary:after {
content: "";
position: absolute;
height: 2em;
top: 3em;
left: -2em;
right: -2em;
}
Hope it helps 😊
B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.
B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.
B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.
BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now
And could you also help me with one thing. I have to add thing like when you open mega menu background is turning into blury. Like on this example
This is an accepted solution.
@Aleksander22, change the previous code in theme.liquid file like this
<script>
document.addEventListener("DOMContentLoaded", (event) => {
let items = document.querySelector(".header__inline-menu").querySelectorAll("details");
items.forEach(item => {
item.addEventListener("mouseover", () => {
item.setAttribute("open", true);
item.querySelector("ul").addEventListener("mouseleave", () => {
item.removeAttribute("open");
});
item.addEventListener("mouseleave", () => {
item.removeAttribute("open");
});
});
});
const listItems = document.querySelectorAll('.list-menu');
const mainContent = document.getElementById('MainContent');
listItems.forEach(item => {
item.addEventListener('mouseenter', () => {
mainContent.style.filter = 'blur(4px)';
});
item.addEventListener('mouseleave', () => {
mainContent.style.filter = 'none';
});
});
});
</script>
Result:
B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.
B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.
B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.
BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now
And last thing my content move to the left and it was in center how can I solve that
@Aleksander22, You mean this one ?
If so you could add this code to end of base.css file
.mega-menu__list {
display: flex!important;
justify-content: center;
}
.mega-menu__list > li {
width: 16.67%;
}
B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.
B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.
B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.
BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024