大数跨境

Shopify制作 | Dawn主题设置PC端主菜单不用点击,只需要鼠标移动上去就能展开下级栏目

Shopify制作 | Dawn主题设置PC端主菜单不用点击,只需要鼠标移动上去就能展开下级栏目 广州网站开发织晶
2026-03-16
2
导读:在Shopify制作过程中,如果使用了Dawn主题,可能出现PC端上部主导航只有点击了一级栏目才能展开下级菜单,如果想要鼠标移动上去就能自动展开二级菜单,那怎么操作? 下面给出了解决方案,跟着往下看!

Shopify制作过程中,如果使用了Dawn主题,可能出现PC端上部主导航只有点击了一级栏目才能展开下级菜单,如果想要鼠标移动上去就能自动展开二级菜单,那怎么操作? 下面给出了解决方案,跟着往下看!

Add a JavaScript Code (Most Recommended)

This method is widely used in the Shopify Community and effectively converts the click-based menu to hover on desktop/PC .

In your Shopify admin, go to Online Store > Themes.

Find your current Dawn theme, click the ... (Actions) button, and select Edit code.

In the code editor, under the Layout folder, open theme.liquid.

Scroll to the very bottom of the file and paste the following code just before the </body> tag.

如下图:

Snippet Code:

   <script>  // Enable hover dropdown for desktop menu in Dawn theme  if (window.innerWidth > 990) {     document.querySelectorAll('.header__inline-menu details').forEach((menu) => {      menu.addEventListener('mouseenter'() => {        menu.setAttribute('open'true);        // Optional: Also set the ARIA attribute for accessibility        const summary = menu.querySelector('summary');        if (summary) summary.setAttribute('aria-expanded''true');      });      menu.addEventListener('mouseleave'() => {        menu.removeAttribute('open');        const summary = menu.querySelector('summary');        if (summary) summary.setAttribute('aria-expanded''false');      });    });  }</script>

如果您近期有Shopify制作的考虑,请联系我们,织晶网络是广州一家专业的外贸独立站制作公司,我们能给予合理的价格与优秀的制作,广州市区可预约面谈

wxqrcode.png

 长按二维码加微信联系 



【声明】内容源于网络
0
0
广州网站开发织晶
广州网站建设,外贸网站制作,番禺网站设计,小程序开发,独立站开发,Shopify搭建,域名注册,服务器搭建,企业邮箱注册,网站备案
内容 270
粉丝 0
广州网站开发织晶 广州网站建设,外贸网站制作,番禺网站设计,小程序开发,独立站开发,Shopify搭建,域名注册,服务器搭建,企业邮箱注册,网站备案
总阅读67
粉丝0
内容270