I've marked up a simple one-page site that has a absolute positioned nav-bar at the top of the page for scrolling to sections of the page using anchors. You can see my terrible code live here:
http://codepen.io/anon/pen/nlcsK
You'll also notice that there is a 'Play' div
at the top of the page as what I'd really like to do is to have the page automatically scroll to different anchors at different times after you hit 'Play'.
Unfortunately, my jQuery is even worse that my HTML/CSS so I have no idea how to do this! Any (step by step) help would be much appreciated!
<nav id="nav">
<a href="#section-one">One</a>|
<a href="#section-two">Two</a>|
<a href="#section-three">Three</a>|
<a href="#section-four">Four</a>
</nav>
<div id="section-one" class="cover">
<h1 id="play">Play</h1>
</div>
<div id="section-two" class="cover">
</div>
<div id="section-three" class="cover">
</div>
* {
margin:0px;
padding:0px;
height:100%;
}
#nav {
position:fixed;
}
#section-one {
background-color:white;
}
#section-two {
background-color:orange;
}
#section-three {
background-color:grey;
}
#section-four {
background-color:green;
}
.cover {
background: no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height: 100%;
}
#play {
width:60px;
height:60px;
background-color:red;
margin: 0px auto;
}
If you add this jQuery-Code:
Everytime you hit a HTML anchor link the action will be overidden and jquery will scroll to it.
Same way at doing an animation for the play button. You have to get the targets position, then you can scroll to it:
where 1000 is the time it needs to scroll in miliseconds, you can change that.