admin管理员组

文章数量:1296464

I am very new to web design, and am going to make a simple webpage. I like the idea of this webpage:

/

Where the top part doesn't scroll with the rest of the page, giving a neat scrolling effect, as well as where the very top of the scrollable part is just at the bottom of the web page (as in with one "click" of the mouse scroll wheel, you'll immediately begin to see the scrolling part). How is something such as this made possible?

I am very new to web design, and am going to make a simple webpage. I like the idea of this webpage:

http://dropplets./

Where the top part doesn't scroll with the rest of the page, giving a neat scrolling effect, as well as where the very top of the scrollable part is just at the bottom of the web page (as in with one "click" of the mouse scroll wheel, you'll immediately begin to see the scrolling part). How is something such as this made possible?

Share Improve this question asked Dec 9, 2013 at 4:34 AggieDevAggieDev 5,0459 gold badges28 silver badges49 bronze badges 2
  • see the page in firebug and see what HTML structure and CSS styles they used. – Moinul Hossain Commented Dec 9, 2013 at 4:45
  • use background-attachment:fixed css property. Check simple w3school example here – Free-Minded Commented Dec 9, 2013 at 4:50
Add a ment  | 

3 Answers 3

Reset to default 5

just give position:fixed; and z-index:1 to the top part which you want to back on scroll and in wrapper give position:relative; z-index:2;

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<style>
.fix-div{position:fixed; height:100%; width:100%; left:0; top:0; z-index:1;}
#wrapper{position:relative; z-index:2; margin:100% 0 0;}
</style>
</head>

<body>
    <div class="fix-div">
        Fix div content goes here...
    </div>
    <div id="wrapper">
        Your content goes here...
    </div>
</body>
</html>

Fiddle : link

Code :

CSS :

.main{
    background-color:green;
    width:100%;
    height:100px;
    padding:0px;
    margin:0px;
    z-index:1;
    position:fixed;
    top:0px;
}

.content{
    height:1000px;
    width:100%;
    margin-top:100px;
    z-index:10;
    background-color:red;
    position:relative;
}

HTML :

<div class='main'></div>
<div class='content'></div>

For the parts which you don't want to scroll set css as position : absolute; top:0;left:0;

本文标签: javascriptHow to make part of the webpage not scroll with the rest of the pageStack Overflow