You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

弹出侧边菜单低屏幕高度显示异常的修复方案咨询

修复小屏幕高度下侧边菜单遮挡问题

问题根源

你的侧边菜单中,.menu-main 未设置高度限制,而 .menu-footer 采用绝对定位固定在底部,当屏幕高度不足时,菜单主体内容会被底部 footer 覆盖。以下是几种针对性修复方案:


方案一:让菜单主体可滚动(推荐)

该方案既能保留 footer 内容,又能保证所有菜单链接可访问,是用户体验最优的处理方式。

修改 CSS:

.menu-general {
  position:fixed;
  width:400px;
  top:0;
  right:-400px;
  bottom:0;
  z-index:9999;
  background-color:black;
  /* 添加flex布局,让内部元素自动分配空间 */
  display: flex;
  flex-direction: column;

  @media screen and (max-width: 767px){
    width: 100vw;
    right: -100vw;
  }
}

.menu-main {
  /* 让菜单主体占据除footer外的剩余空间,超出内容自动滚动 */
  flex: 1;
  overflow-y: auto;
  padding: 60px 0 20px 60px; /* 调整内边距,避免和关闭按钮、footer重叠 */
  margin: 0; /* 移除ul默认边距 */
}

.menu-general .menu-footer {
    display: flex;
    align-items: center;
    gap: 40px;
    flex-wrap: wrap;
    /* 移除绝对定位,改为flex布局的底部元素 */
    position: relative;
    padding: 40px 0 40px 60px;
    background: violet;
}

方案二:小屏幕高度下优化文字与间距

若不想让菜单滚动,可针对小高度屏幕缩小字体、减少元素间距,避免内容重叠。

添加高度媒体查询:

/* 当屏幕高度小于600px时调整样式 */
@media screen and (max-height: 600px) {
  .menu-main li, .menu-main li a {
    font-size: 24px; /* 缩小菜单文字 */
  }
  .menu-main li {
    margin: 0 0 8px; /* 减小列表项间距 */
  }
  .menu-up-control-close i {
    font-size: 30px; /* 缩小关闭按钮 */
    margin: 30px 0 0 30px; /* 调整关闭按钮位置 */
  }
  .menu-general .menu-footer {
    padding: 20px 0 20px 60px; /* 减小footer内边距 */
  }
}

方案三:极端小高度下隐藏footer

如果屏幕高度极小(比如低于450px),可直接隐藏 footer,优先保证菜单链接的显示:

@media screen and (max-height: 450px) {
  .menu-general .menu-footer {
    display: none;
  }
  /* 调整菜单主体底部内边距,避免内容贴底 */
  .menu-main {
    padding-bottom: 40px;
  }
}

额外优化:简化冗余JS代码

你原有的JS中,宽屏和窄屏的动画逻辑完全重复,可简化为:

let menuGeneral = $('#menu-general');

$('#menu-up-control').click(function () {
    $('.wrapper-main').css('opacity', '0.7');
    menuGeneral.animate({ right: '0' }, 500);
});

$('#menu-up-control-close').click(function () {
    $('.wrapper-main').css('opacity', '1');
    const targetRight = $(document).width() > 767 ? '-400px' : '-100vw';
    menuGeneral.animate({ right: targetRight }, 500);
});

内容的提问来源于stack exchange,提问作者Jane

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 02:27:41