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
3 Answers
Reset to default 5just 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
版权声明:本文标题:javascript - How to make part of the webpage not scroll with the rest of the page? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741637341a2389716.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论