[英]Shopify Debut Theme Adding padding-bottom: 60px after page loads to the html element
出于某种原因,在页面加载后,样式属性被添加到带有padding-bottom: 60px;
的 HTML 元素中padding-bottom: 60px;
我如何获得它以便在页面加载时不将此属性添加到 HTML 元素中。 这令人沮丧,因为我无法使用 CSS 将其删除。
我注意到其他人遇到了这个问题,我尝试复制其中一个将代码添加到 theme.js 的解决方案
$(window).load(function() {
$('html').removeAttr('style');
});
在我的测试中,这只发生在预览主题并且 Shopify 在正文底部插入一个iframe
元素(它的 id 为preview-bar-iframe
)。
它有 60 像素高,脚本会在html
元素的底部添加一些填充。 我想是为了让你看到所有的页面。
我使用此脚本在几秒钟后删除预览和填充。
// Remove the annoying Shopify #preview-bar-iframe
window.setTimeout(() => {
let previewBar = document.getElementById('preview-bar-iframe')
if (previewBar) {
previewBar.style['display'] = 'none';
document.documentElement.removeAttribute('style');
}
}, 2000);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.