jquery - 即使滚动条可见,也使绝对 div 高度为 100%

标签 jquery html css

HTML

<div class="modalPage"style="display:none;"></div>

CSS:

.modalPage{
    position:absolute;
    width:100%;
    height:100%;
    background-color:#000000;
    filter:alpha(opacity=60);
    opacity:0.6;
    -moz-opacity:0.6;
    z-index:100;
    top:0px;
}

JS:

$(".modalPage").toggle();

效果:

enter image description here

现在一切之上都有一层。因此用户无法再与该网站进行交互。

问题:

enter image description here

当由于内容过多而出现滚动条时,图层实际上不会像您在图像中看到的那样拉伸(stretch)高度。

如何使绝对 div 自动拉伸(stretch)?

最佳答案

................................................

您好,现在不要使用宽度高度,现在用于定位固定

像这样

.modalPage{
    position:fixed;
    background-color:#000000;
    filter:alpha(opacity=60);
    opacity:0.6;
    -moz-opacity:0.6;
    z-index:100;
    top: 0;
    left:0;
right:0;
bottom:0;
}

关于jquery - 即使滚动条可见,也使绝对 div 高度为 100%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12689726/

相关文章:

jQuery .on() 与将事件绑定(bind)到选择器?

javascript - 根据浏览器语言重定向

jquery - 如何显示和隐藏一个div

html - IE9 中的图像模糊、内容移动、无法重现的错误

jquery - 使用 jquery 在按钮单击时显示新的 div 并隐藏第一个 div

javascript - 单击其他元素与单击此元素相同

jquery - 使用 jquery 防止输入字段中出现特殊字符

html - 在 Wordpress 中对齐中心 Aweber 表单

css - 字体粗细 :300 doesn't work in Chrome

php - 新的 HTML/CSS 代码不会将 post 变量传递给 PHP shell_exec