简体   繁体   English

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

[英]Make absolute div height 100% even when scrollbar is visible

HTML HTML

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

CSS: 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: JS:

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

Effect: 影响:

在此输入图像描述

Now there is a layer above everything. 现在,一切之上都有一层。 So the user cannot interact with the website anymore. 因此,用户无法再与该网站进行交互。

Problem: 问题:

在此输入图像描述

When scrollbar appears because of much content, the layer actually does not stretch in height like you see in the image. 当滚动条由于内容过多而出现时,该图层实际上不会像您在图像中看到的那样在高度上拉伸。

How can I make the absolute div stretch automatically? 如何自动使div绝对拉伸?

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

hi now don't used width or height and now used to position fixed 您好,现在使用widthheight ,现在用于fixed位置

as like this 像这样

.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;
}
.modalPage{
    position:fixed;
    width:100%;
    height:100%;
    background-color:#000000;
    filter:alpha(opacity=60);
    opacity:0.6;
    -moz-opacity:0.6;
    z-index:100;
    top: 0;
    left:0;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM