I have following HTML code:
<div id="wrapper">
<div class="page" id="first">
Test<br/>
Test<br/>
Test<br/>
Test<br/>
Test<br/>
Test<br/>
Test<br/>
Test<br/>
Test<br/>
Test<br/>
Test<br/>
Test<br/>
Test<br/>
<div class="nav bottom"><a href="#second">Second</a></div>
</div>
<div class="page" id="second">
</div>
<div class="page" id="third">
</div>
</div>
and following CSS code:
html, body { height:100% }
#wrapper {
height:100%;
min-height:100%;
min-width:100%;
overflow:hidden;
position:relative;
width:100%;
}
.page {
height:100%;
overflow:scroll;
position:relative;
width:100%;
}
.nav {
position:absolute;
text-align:center;
width:100%;
}
.nav.top {
top:0;
}
.nav.bottom {
bottom:0;
}
.nav a {
display:block;
height:25px;
line-height:25px;
margin:0 auto;
width:160px;
}
As you may see, wrapper is the element that “simulates” browser window, basically the idea is to create “scrollable” pages of the website.
Everything works perfectly, but I’m facing one problem. If div.page has more content, scroll bar appear as expected, but the .nav div is positioned at the bottom of the browser window, not the div#wrapper.
Does anybody know how to fix this issue?
First of all your
.navis going to be relative to the.pageand not the#wrapper. In order for.navto be relative to#wrapper, you will need to move it out of the.pagedivand into#wrapper.However it is at the bottom because you have set a
height:100%on both#wrapperand.page, which means your.navwould appear at the bottom.EDIT : I think I understand what you want. If you wrap the contents in the
.pagecontainer a newdive.g..innerContentand set that toposition:relativeit should achieve what you are trying to do. Live example: http://jsfiddle.net/Rerqm/1/HTML:
CSS: