From 4696b75bf3a74146f59c246397863a4ea0e9590c Mon Sep 17 00:00:00 2001 From: pushuo Date: Mon, 19 Dec 2022 10:37:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E8=88=AA=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E9=98=B2=E6=AD=A2=E5=B0=8F=E5=B1=8F=E5=B9=95=E4=B8=8B?= =?UTF-8?q?(=E9=9D=9E=E6=89=8B=E6=9C=BA=E7=AB=AF)=EF=BC=8C=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=88=97=E6=95=B0=E8=BF=87=E5=A4=9A=20=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=94=99=E8=AF=AF=20->=20https://gitee.com/beikeshop/?= =?UTF-8?q?beikeshop/issues/I66KP9=3Ffrom=3Dproject-issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/beike/shop/default/js/header.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/resources/beike/shop/default/js/header.js b/resources/beike/shop/default/js/header.js index 572fdb62..3fcf4ee4 100644 --- a/resources/beike/shop/default/js/header.js +++ b/resources/beike/shop/default/js/header.js @@ -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)'}); + } + } + }); });