Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scrolling overlay div without scrolling entire page

Tags:

html

css

I have a main page with some content on it. I then have a modal that pops up which is longer than the screen itself so I have to scroll to see it. What do I need to do to my CSS to make only the modal div scroll instead of the whole page?

Here is the CSS for the modal

#overlay {
    visibility: hidden;
    position: absolute;
    left: 45%;
    width:auto;
    border:1px solid #A17E13;
    height:auto;
    text-align:left;
    z-index: 1000; 
}
#overlay div {
    background-color:#FCFBEC;
}

Here is the HTML :

<html><body>
    <div>main page</div>
    <div id="overlay">
    <div>
        <div>
             <asp:Label ID="test">Text for modal here</asp:Label>
        </div>
    </div>
    </div>
</body></html>
like image 305
user541597 Avatar asked Feb 26 '13 19:02

user541597


1 Answers

has the entire page not to be scrollable except of the modal div? if so can you try position:fixed; on the page. the modal has to be outside with position:absolute;

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#overlay {
    /*visibility: hidden;*/
    position: fixed;
    left: 45%;
    width:auto;
    border:1px solid #A17E13;
    height:900px;
    text-align:left;
    background-color:orange;
}
.scroller {
    height:3000px;
    width:400px;
    background-color:green;
}
</style>
</head>
<body>
    <div id="overlay">
        this is not moving
    </div>

    <div>
        <div class="scroller">
             <asp:Label ID="test">This is moving if big enough</asp:Label>
        </div>
    </div>
</body>
</html>

Fiddle here

like image 139
caramba Avatar answered Sep 30 '22 03:09

caramba