简体   繁体   English

购物 | 首次亮相主题静态标题反弹

[英]Shopify | Debut theme static header bounce

I'm editing the Debut theme on Shopify.我正在 Shopify 上编辑 Debut 主题。 I wanted to make the header static so I found this tutorial here: https://community.shopify.com/c/Shopify-Design/Sticky-Fixed-Header-and-Navigation-for-Debut-Theme/mp/518018/highlight/true#M132407我想让标题静态,所以我在这里找到了这个教程: https : //community.shopify.com/c/Shopify-Design/Sticky-Fixed-Header-and-Navigation-for-Debut-Theme/mp/518018/高亮/真#M132407

Everything is working as intended until after all the content is loaded, at which point it "bounces" in order to position the main content under the header.一切都按预期工作,直到所有内容都加载完毕,此时它会“弹跳”以将主要内容定位在标题下。 I tried to find the cause, and I realized that removing the $(window).on("load", headerSize);我试图找到原因,我意识到删除$(window).on("load", headerSize); from the code below stops it, but does not reposition it.从下面的代码停止它,但不重新定位它。 I have no clue how to use JavaScript and I assume I have to set a shorter animation or some kind of timer on the existing code in order to load the page instantly, or without the user noticing the bounce.我不知道如何使用 JavaScript,我假设我必须在现有代码上设置更短的动画或某种计时器,以便立即加载页面,或者在用户没有注意到反弹的情况下。

JavaScript: JavaScript:

function headerSize() {
  var $headerHeight = $('div#shopify-section-header').outerHeight();
  $('#PageContainer').css('padding-top', $headerHeight);
}

$(window).on("load", headerSize);
$(window).on("resize", $.debounce(500, headerSize));

The easiest way to achive what you want is to add the following at the bottom of your css file:实现您想要的最简单方法是在 css 文件底部添加以下内容:

#shopify-section-header {
  z-index: 999999;
  position:fixed;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM