Pure CSS Navigation with Target

1/14/2015
Pure CSS Navigation with Target



<nav>
  <a href="#satu">1</a>
  <a href="#dua">2</a>
  <a href="#tiga">3</a>
  <a href="#empat">4</a>
  <a href="#lima">5</a>
</nav>
<label>Pure CSS Navigation with :target</label>
<div id="satu" class="page">
  <h1>Konten halaman satu</h1>
</div>
<div id="dua" class="page">
  <h1>Konten halaman dua</h1>
</div>
<div id="tiga" class="page">
  <h1>Konten halaman tiga</h1>
</div>
<div id="empat" class="page">
  <h1>Konten halaman empat</h1>
</div>
<div id="lima" class="page">
  <h1>Konten halaman lima</h1>
</div>

@import url(http://fonts.googleapis.com/css?family=Lato);

html, body {
    overflow: hidden;
    font-family: 'Lato';
}

nav {
    position: fixed;
    z-index: 10;
    background-color: white;
    display: block;
    width: 100%;
    padding: 0px;
    margin: 0;
    box-sizing: border-box;
    font-size: 0;
    line-height: 0;
}

nav a {
    font-size: 15px;
    letter-spacing: 1px;
    text-decoration: none;
    color: #222d38;
    border: 1px solid rgba(34, 45, 56, 0.1);
    padding: 22px;
    margin: 10px 0 10px 10px;
    display: inline-block;
    text-transform: uppercase;
}

.page {
    position: fixed;
    -moz-transform: translate(0, -100%);
    -ms-transform: translate(0, -100%);
    -webkit-transform: translate(0, -100%);
    transform: translate(0, -100%);
    -moz-transition: all 0.5s ease-in-out;
    -o-transition: all 0.5s ease-in-out;
    -webkit-transition: all 0.5s ease-in-out;
    transition: all 0.5s ease-in-out;
    width: 100%;
    height: 100%;
    top: 0%;
    left: 0%;
    z-index: 1;
}

.page:target {
    -moz-transform: translate(0, 0);
    -ms-transform: translate(0, 0);
    -webkit-transform: translate(0, 0);
    transform: translate(0, 0);
}

.page:target ~ .page {
    -moz-transform: translate(0, 100%);
    -ms-transform: translate(0, 100%);
    -webkit-transform: translate(0, 100%);
    transform: translate(0, 100%);
}

.page h1 {
    position: absolute;
    width: 100%;
    padding: 0 90px;
    margin: 0;
    box-sizing: border-box;
    display: inline-block;
    text-align: center;
    font-size: 90px;
    -moz-transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    color: white;
    top: 50%;
    left: 50%;
}

label {
    position: fixed;
    width: 100%;
    padding: 0 90px;
    margin: 0;
    box-sizing: border-box;
    display: inline-block;
    text-align: center;
    font-size: 20px;
    -moz-transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    color: rgba(45, 56, 67, 0.5);
    top: 50%;
    left: 50%;
}

#satu {
    background-color: #f56954;
}

#dua {
    background-color: #00c0ef;
}

#tiga {
    background-color: #ffa812;
}

#empat {
    background-color: #0073b7;
}

#lima {
    background-color: #00b29e;
}


Artikel Terkait

Next Article
« Prev Post
Previous Article
Next Post »
Penulisan markup di komentar
  • Untuk menulis huruf bold gunakan <strong></strong> atau <b></b>.
  • Untuk menulis huruf italic gunakan <em></em> atau <i></i>.
  • Untuk menulis huruf underline gunakan <u></u>.
  • Untuk menulis huruf strikethrought gunakan <strike></strike>.
  • Untuk menulis kode HTML gunakan <code></code> atau <pre></pre> atau <pre><code></code></pre>, dan silakan parse kode pada kotak parser di bawah ini.

Disqus
Tambahkan komentar Anda

4 comments

Iya memang cocok

Balas

Katou ijin pake untuk lomba ya :-bd

Balas

Iya boleh

Balas

Silakan tambahkan komentar sesuai dengan topik, terima kasih.