修复导航菜单防止小屏幕下(非手机端),配置列数过多 显示错误 -> https://gitee.com/beikeshop/beikeshop/issues/I66KP9?from=project-issue

This commit is contained in:
pushuo 2022-12-19 10:37:12 +08:00 committed by Edward Yang
parent f97496d6de
commit 4696b75bf3
1 changed files with 15 additions and 0 deletions

View File

@ -74,4 +74,19 @@ $(function () {
$('.offcanvas-right-cart-count').text(res.data.quantity);
$('.offcanvas-right-cart-amount').text(res.data.amount_format);
}
// 导航菜单防止小屏幕下(非手机端),配置列数过多 显示错误
$('.menu-wrap > ul > li').each(function(index, el) {
if ($(el).children('.dropdown-menu').length) {
const offsetLeft = $(el).children('.dropdown-menu').offset().left;
const width = $(el).children('.dropdown-menu').width();
const windowWidth = $(window).width();
if (offsetLeft < 0) {
$(el).addClass('position-static')
.children('.dropdown-menu')
.css({'left': (windowWidth - width) / 2, 'transform': 'translate(0, 0.5rem)'});
}
}
});
});