Skip to content

Instantly share code, notes, and snippets.

@dracon
Created October 16, 2016 20:26
Show Gist options
  • Save dracon/0c4d6439d639e83de6036ec815d1bf20 to your computer and use it in GitHub Desktop.
Save dracon/0c4d6439d639e83de6036ec815d1bf20 to your computer and use it in GitHub Desktop.
Simple single page
<header class="top sticky-wrapper">
<ul class="nav">
<li><a href="#sOne">side 1</a></li>
<li><a href="#sTwo">side 2</a></li>
<li><a href="#sThree">side-3</a></li>
<li><a href="#sFour">side-4</a></li>
</ul>
</header>
<section class="wrapper side-1">
<a class="anchor" id="sOne"></a>
<h1 class="title">
Hello Wolfgang!
</h1>
<h2 class="subtitle fadeIn wait-3s">
A new day, a new chance! ;-)
</h2>
<p class="fadeIn wait-4s"><button>Send</button>
</p>
</section>
<section class="wrapper side-2">
<a class="anchor" id="sTwo"></a>
<h2>Side 2</h2>
</section>
<section class="wrapper side-3">
<a class="anchor" id="sThree"></a>
<h2>Side 3</h2>
</section>
<section class="wrapper last side-4">
<a class="anchor" id="sFour"></a>
<h2>Side 4</h2>
</section>
<footer>
<div class="jumbotron">Footer</div>
</footer>
// ------------------------------
// http://twitter.com/mattsince87
// ------------------------------
function scrollNav() {
$('.nav a').click(function(){
//Toggle Class
$(".active").removeClass("active");
$(this).closest('li').addClass("active");
var theClass = $(this).attr("class");
$('.'+theClass).parent('li').addClass('active');
//Animate
$('html, body').stop().animate({
scrollTop: $( $(this).attr('href') ).offset().top
}, 400);
return false;
});
$('.scrollTop a').scrollTop();
}
scrollNav();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
html,
body {
margin: 0;
padding: 0;
height: 100vh;
}
header {
height: 80px;
background: rgba(0, 0, 0, 0.4);
width: 100vw;
display: flex;
align-content: center;
justify-content: flex-end;
&.sticky-wrapper {
position: fixed;
z-index: 2;
}
ul.nav {
list-style: none;
display: flex;
align-items: stretch;
justify-content: flex-end;
padding: 0;
margin: 0 2em 0 0;
li {
margin-left: 10px;
display: flex;
align-items: stretch;
justify-content: center;
height: inherit;
background: #222;
a {
color: #fff;
display: flex;
align-items: center;
transition: all .5s;
padding: 10px;
text-transform: uppercase;
letter-spacing: 2px;
text-decoration: none;
box-sizing: border-box;
height: inherit;
&:hover {
background-color: rgba(30, 60, 90, 0.6);
color: #ad9312;
}
}
}
}
}
.wrapper {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
height: 100%;
position: relative;
overflow: hidden;
z-index: 1;
&.last {
margin-bottom: 40vh;
}
a.anchor {
position: absolute;
top: 0;
width: 20px;
height: 20px;
background: transparent;
visibility: none;
}
}
.title {
animation: type 3s steps(15), blink .5s step-end infinite alternate;
width: 15ch;
white-space: nowrap;
overflow: hidden;
border-right: 3px solid;
font-family: monospace;
font-size: 3em;
}
@keyframes type {
from {
width: 0;
}
}
@keyframes blink {
50% {
border-color: transparent;
}
}
.subtitle {
font-family: sans-serif;
}
.fadeIn {
animation: fadeIn 1s ease;
animation-fill-mode: both;
}
.wait-3s {
animation-delay: 3s;
}
.wait-4s {
animation-delay: 4s;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
button {
background-color: #aa0202;
padding: 10px 20px;
border-radius: 5px;
border: 1px solid darkred;
color: #ededed;
font-weight: bold;
font-size: 1.5em;
transition: all 0.5s;
&:hover {
background-color: darken(#aa0202, 20%);
}
}
.side-1 {
background: url('http://b2v.no/images/20161005_194150.jpg') no-repeat;
background-attachment: fixed;
background-size: cover;
color: #fff;
}
.side-2 {
background: #000;
color: #fff;
}
.side-3 {
background: url('http://b2v.no/images/2016/09/21/space2.png') no-repeat;
background-attachment: fixed;
background-size: cover;
color: #fff;
}
.side-4 {
background: #936231;
color: #fff;
}
footer {
height: 40vh;
background: #ad12ed;
position: fixed;
width: 100vw;
bottom: 0;
z-index: -1;
padding: 1em;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
}
.jumbotron{
font-size: 20vw;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment