div样式position:fixed,不随屏幕滚动而滚动,导致屏幕太小时弹出层被遮挡,无法滚动查看的解决办法

时间:2023-03-09 03:12:51
div样式position:fixed,不随屏幕滚动而滚动,导致屏幕太小时弹出层被遮挡,无法滚动查看的解决办法
  window.onscroll = function () {
var sl = -Math.max(document.body.scrollTop, document.documentElement.scrollTop);
//document.getElementsByClassName('layui-m-layerchild').style.Top = sl + 'px';
$("#fixdiv").css("top", sl + "px"); };

根据计算屏幕滚动时距顶部的距离,设置弹出层top为负的