如何解决Sitecore 9.3position: fixed
中的导航栏问题。我在博客上看到了一些解决方案,但它只解决了 Sitecore 8 版本的问题。
基本上,当我在 Sitecore 体验编辑器中打开部分设计时,我已将导航栏设置为在主题 css 文件中固定的位置,并在scWebEditRibbon下方显示导航栏。我还看到scWebEditRibbon现在位置固定,但它仍然不能解决我的问题,因为我的元素上也有固定位置。
我通过使用Richard Szalay提供的脚本解决了这个问题,我只是更改了变量,如您在此处看到的:这是脚本:
// Repositions a position-fixed header so that it always appears under the SC experience editor ribbon
define(["sitecore"], function (Sitecore) {
return {
priority: 50,
execute: function (context) {
// TODO: Change this CSS selector to suit your application
var FIXED_NAV_SELECTOR = '#navbar';
// the 'cross piece' is a blank div that is sized to match the iframe content (where the actual ribbon is)
var scWebEditRibbon = window.parent.document.getElementById('scWebEditRibbon');
var nav = window.parent.document.querySelector(FIXED_NAV_SELECTOR);
if (scWebEditRibbon && 'MutationObserver' in window) {
var observer = new MutationObserver(function (mutations) {
nav.style.top = scWebEditRibbon.style.height;
});
observer.observe(scWebEditRibbon, { attributes: true, attributeFilter: ['style'] });
}
}
};
});