Full-Screen Navigation Bar- Website Design
Full-Screen Navigation Bar HTML
<div id="nav-trigger" class="nav-trigger open">
<span
class="line"></span>
<span
class="line"></span>
<span
class="line"></span>
</div>
<nav id="nav"
class="out">
<ul>
<li><span
class="nav-label">Home</span></span></li>
<li><span
class="nav-label">About</span></li>
<li><span class="nav-label">Work</span></li>
<li><span
class="nav-label">Blog</span></li>
<li><span class="nav-label">Contact</span></li>
</ul>
</nav>
<section id="header"
class="header">
<h1 id="heading">Full Screen
Nav</h1>
</section>
<section class="content">
<p>We're going aerial pingpong no dramas as cross as a mickey mouse
mate. Flat out like a bities no dramas as cross as a wobbly. Mad as a bush
bash as dry as a kindie. As stands out like ford also grab us a chuck a
sickie. Built like a moolah bloody khe sanh. Get a dog up ya chokkie how as
cunning as a garbo. Lets get some show pony flamin lets throw a roadie. Come
a sheila to come a cab sav.</p>
<p>Gutful of servo bloody as busy as a moolah. Built like a ropeable
piece of piss built like a relo. Lets throw a two up piece of piss she'll be
right brick sh*t house. Built like a dunny piece of piss lets throw a esky.
She'll be right struth my built like a tucker. rage on bloody built like a
garbo.</p>
<p>It'll be dinky-di
come a brumby. He hasn't got a shit house with shazza got us some buckley's
chance. Trent from punchy barbie where shazza got us some chuck a sickie.
Mad as a swagger my hottie. As busy as a mate's rate mate stands out like a
trackie dacks. As busy as a bathers also grab us a dipstick.</p>
<p class="credit">This placeholder text is from <a
href="http://boganipsum.com">Bogan Ipsum</a></p>
</section>
Full-Screen Navigation Bar CSS
@import "bourbon";
@import
url(https://fonts.googleapis.com/css?family=Patua+One);
@import
url(https://fonts.googleapis.com/css?family=Open+Sans);
// vars
$headings:
'Patua One', cursive;
$white: #fff;
$grey-black: #222;
$olive:
#364e41;
body {
background: #fff;
height:
100%;
font-family: 'Open Sans', sans-serif;
}
p {
line-height: 1.5;
}
// Nav Button
.nav-trigger {
position: fixed;
width: 110px;
height: 98px;
right: 0px;
top: 0px;
cursor: pointer;
z-index: 200;
@include transform-origin(110px 0px);
@include transform(scale(0.6));
@include transition(background
0.3s linear);
}
.nav-trigger.open {
background:
$grey-black;
}
.nav-trigger.close {
background:
transparent;
}
.line {
display: block;
position: absolute;
width: 80px;
height: 8px;
background: $white;
left: 15px;
@include
transform-origin(0px 4px);
@include transition (opacity 0.3s
$ease-in-out-cubic 0s, transform 0.24s $ease-in-out-cubic 0s);
}
@for
$i from 1 through 3 {
.line:nth-child(#{$i}) {
top: 16px + (($i)-1)*28;
}
}
.close
.line:nth-child(1) {
@include transform(translateX(11px)
rotate(45deg));
}
.close .line:nth-child(2) {
opacity:
0;
}
.close .line:nth-child(3) {
@include
transform(translateX(11px) rotate(-45deg));
}
// Full page
Navigation
nav {
width: 100%;
height: 100%;
position: fixed;
z-index: 100;
}
nav.out
{
pointer-events: none;
}
nav.in {
pointer-events: auto;
}
nav ul, li {
display:
block;
padding: 0;
margin: 0;
width:
100%;
cursor: pointer;
}
nav ul {
height:
100%;
width: 100%;
position: absolute;
}
nav
li {
height: 20%;
position: relative;
background: $grey-black;
color: $white;
font-family:
$headings;
}
nav li:hover {
background: $olive;
}
@for
$i from 1 through 5 {
nav.in li:nth-child(#{$i}) {
@include transition(transform 0.5s $ease-out-cubic (0.1s*$i), opacity
0.5s linear (0.1s*$i));
}
}
@for $i from 5 through 1
{
nav.out li:nth-child(#{$i}) {
@include
transition(transform 0.3s $ease-in-cubic (0.05s*(5-$i)), opacity 0.3s linear
(0.05s*(5-$i)));
}
}
nav.out li {
@include
transform(translateY(300%));
opacity: 0;
}
nav.in li
{
@include transform(translateY(0));
opacity: 1;
}
.nav-label
{
position: absolute;
width: 100%;
left:
0;
text-align: center;
height: 16px;
top: 50%;
margin-top: -8px;
text-transform:
uppercase;
}
// site content
.header {
background:
url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/53148/bg.jpg);
background-size: cover;
position: relative;
width:
100%;
min-height: 100%;
top: 0px;
}
.header
h1 {
width: 100%;
color: #fff;
position:
absolute;
margin: 0;
font-family: $headings;
text-align: center;
display: block;
top: 50%;
}
.content
{
@include box-sizing(border-box);
max-width:
600px;
padding: 20px;
margin: 0 auto;
}
.credit
{
color: #364e41;
}
.credit a {
color:
#364e41;
}
Full-Screen Navigation Bar JAVASCRIPT
// selected elements
var navTrigger =
document.getElementById('nav-trigger');
var nav =
document.getElementById('nav');
var header =
document.getElementById('header');
var heading =
document.getElementById('heading');
var labels =
document.getElementsByClassName('nav-label');
// sizing
var
windowHeight = window.innerHeight;
var windowWidth =
window.innerWidth;
var fontSize = windowHeight*0.1;
var
headingSize = windowWidth*0.1;
// Event Listening
navTrigger.addEventListener('click',
navToggle);
window.addEventListener('resize', resize);
function
resize() {
windowHeight = window.innerHeight;
windowWidth = window.innerWidth;
fontSize = windowHeight*0.1;
headingSize = windowWidth*0.1;
if(headingSize >
windowHeight*0.3) headingSize = windowHeight*0.3;
for(var i = 0; i < labels.length; i++) {
labels[i].style.fontSize = fontSize+'px';
labels[i].style.height = fontSize+'px';
labels[i].style.marginTop = '-'+fontSize*0.6+'px';
}
header.style.height = windowHeight+'px';
heading.style.fontSize
= headingSize+'px';
heading.style.height = headingSize+'px';
heading.style.marginTop = '-'+headingSize*0.6+'px';
}
function
navToggle(e) {
var closed =
(navTrigger.className.indexOf('close') > 0);
if(closed)
{
navTrigger.className = 'nav-trigger open';
nav.className = 'out';
} else {
navTrigger.className = 'nav-trigger close';
nav.className
= 'in';
}
}
window.onload = resize;
Animated full-screen navigation bar using GASP
Animated full-screen navigation bar HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Animated fullscreen navigation bar using
GASP</title>
</head>
<body>
<div class="main">
<div class="bars"></div>
</div>
<div class="menu">
<div
class="navBefore"></div>
<div
class="nav">
<ul class="navigation">
<li><a
href="#">Home</a></li>
<li><a
href="#">About</a></li>
<li><a
href="#">About</a></li>
<li><a
href="#">Portfolio</a></li>
<li><a
href="#">Contact</a></li>
</ul>
</div>
</div>
</body>
</html>
Animated full-screen navigation bar CSS
* {
margin: 0;
paddig: 0;
box-sizing:
border-box;
}
.main {
position: relative;
height: 100vh;
width: 100%;
background:
url("https://images.pexels.com/photos/933054/pexels-photo-933054.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
overflow: hidden;
}
.main
.bars {
position: fixed;
height: 30px;
width: 50px;
top: 5%;
right: 5%;
display: flex;
flex-direction: column;
align-items:
center;
z-index: 9999999999;
cursor: pointer;
}
.main
.bars::before {
position: absolute;
content: "";
height: 2px;
width: 90%;
background: #fff;
transition: 0.3s linear;
}
.main .bars.active::before {
transform: rotate(45deg);
width: 50%;
top: 5%;
background: #000;
}
.main .bars::after {
position:
absolute;
content: "";
height: 2px;
width: 90%;
background: #fff;
top: 35%;
transition: 0.3s linear;
}
.main .bars.active::after {
transform: rotate(-45deg);
width: 50%;
top: 5%;
background: #000;
}
.menu {
position: fixed;
top: 0;
left: 0;
width: 100%;
height:
100%;
z-index: 999999999;
overflow: hidden;
display: none;
}
.menu .navBefore {
position:
absolute;
margin-left: 100%;
width: 100%;
height: 100%;
background: #017bf5;
}
.menu .nav {
position: relative;
margin-left: 100%;
width:
100%;
height: 100%;
background: #fff;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
}
.menu .nav ul {
opacity:
0;
}
.menu .nav ul li {
list-style: none;
}
.menu
.nav ul li a {
position: relative;
font-size:
4.5rem;
text-decoration: none;
text-align:
center;
color: #666;
}
.menu .nav ul li a:hover,
.menu
.nav ul li.active a {
color: #000;
}
Animated full-screen navigation bar JAVASCRIPT
window.onload = function () {
const bars =
document.querySelector(".bars");
const menu =
document.querySelector(".menu");
bars.addEventListener("click",
function (e) {
this.classList.toggle("active");
if (this.classList.contains("active")) {
gsap.to(".menu", {
duration: 0.1,
display: "flex",
ease:
"expo.in"
});
gsap.to(".navBefore", {
duration: 0.5,
marginLeft: "0",
ease:
"expo.in"
});
gsap.to(".nav", {
duration: 0.8,
marginLeft: "0",
delay: 0.3,
ease: "expo.in"
});
gsap.to(".navigation", {
duration: 1,
opacity:
"1",
delay: 0.8,
ease: "expo.in"
});
}
else {
gsap.to(".navigation", {
duration: 0.2,
opacity:
"0",
ease: "expo.in"
});
gsap.to(".nav", {
duration: 1,
marginLeft:
"100%",
delay: 0.3,
ease: "expo.in"
});
gsap.to(".navBefore", {
duration: 1,
marginLeft: "100%",
delay: 0.5,
ease:
"expo.in"
});
gsap.to(".menu", {
duration: 1,
display: "none",
delay: 1,
ease: "expo.in"
});
}
});
};
Post a Comment