Scroll Nav
by Joshua Powell
HTML
<div class="scrollBar">
<span class="logo">Josh</span>
<ul>
<li>Home</li>
<li>About</li>
<li>Development</li>
<li>Design</li>
</ul>
<div class="scrollMenu">=
<ul>
<li>Home</li>
<li>About</li>
<li>Development</li>
<li>Design</li>
</ul>
</div>
</div>
<div class="body">
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
<p>dddddddd</p>
</div>
CSS
html, body {
margin: 0;
padding: 0;
}
.scrollBar {
background: mediumSeaGreen;
height: 37px;
width: 100%;
position: relative;
top: 20px;
}
.logo {
color: rgba(255, 255, 255, 1.0);
font-size: 28px;
font-family: 'century gothic';
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
padding-left: 10px;
line-height: 37px;
margin-bottom: 10px;
}
.scrollBar > ul {
list-style-type: none;
padding: 0;
margin: 0;
position: absolute;
top:0;
right: 0;
}
.scrollBar > ul > li {
color: rgba(255, 255, 255, 1.0);
font-size: 20px;
font-family: 'century gothic';
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
float: left;
margin-right: 15px;
line-height: 37px;
cursor: pointer;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-ms-transition: all .3s ease-in-out;
-o-transition: all .3s ease-in-out;
}
.scrollBar > ul > li:hover {
color: rgba(235, 226, 21, 1);
}
.scrollMenu {
display: none;
font-size: 30px;
color: rgba(255, 255, 255, 1.0);
font-family: 'century gothic';
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
line-height: 30px;
cursor: pointer;
position: absolute;
right: 15px;
top: 2px;
padding: 1px 5px 1px 5px;
border-radius: 3px;
background: rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.6) inset;
}
.scrollMenu:after {
width: 150px;
content: "";
height: 100%;
position: absolute;
bottom: -10px;
background: transparent;
}
.scrollMenu > ul {
display: none;
float: none;
width: 150px;
border: 2px solid rgba(0, 0, 0, 0.5);
font-size: 20px;
border-radius: 3px;
position: absolute;
right: 0;
top: 34px;
list-style-type: none;
padding: 0;
margin: 0;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-ms-transition: all .3s ease-in-out;
-o-transition: all .3s...
JavaScript
$(window).scroll(function() {
var sBar = $('.scrollBar');
sBar.css({'position' : 'fixed', 'top' : '0', 'left' : '0'});
sBar.children('ul').hide();
$('.scrollMenu').show();
if ($(window).scrollTop() === 0) {
var sBar = $('.scrollBar');
sBar.css({'position' : 'relative', 'top' : '20px', 'left' : '0'});
$('.scrollMenu').hide();
sBar.children('ul').show();
}
});