通过 jquery 创建模态窗口

Creating modal window through jquery

本文关键字:窗口 模态 创建 jquery 通过      更新时间:2023-09-26

我正在尝试在整个网站上创建一个掩码(模态),为此我尝试了:

.css

 #mask 
{
  position:absolute;
  z-index:9000;
  background-color:#000;
  display:none;
}

.js

   $('body').append(' <div id="mask"></div> ');
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();
    $('#mask').css({ 'width': maskWidth, 'height': maskHeight, top: 0, opacity: 1 });

它工作正常,但当我scrolls down没有面具时,面具仅在我网站的可见部分。谁能告诉我解决方案?

使用 position:fixed 使其在滚动时可用。

#mask 
{
  position:fixed;
  z-index:9000;
  background-color:#000;
  display:none;
}