Kali ini kita akan mencoba mebuat sebuah layout web, dengan beberapa menu atau navigasi. Seperti menu home, about dan contact. Namun ketika kita klik menu tersebut kita tidak akan menjumpai halaman yang baru, melainkan masih dihalaman yang sama (index). Teknik melayout seperti ini biasanya disebut One Page Layout.
Untuk tutorial kali ini juga kita akan mencoba membuat menu atau navigasi berada disebelah kiri dari layout utama. Disaat kita melakukan gulir (scroll) kebawah, menu tersebut tetap (Fixed) pada posisi awal.
Langsung saja kita praktekkan ya teman-teman,
<!DOCTYPE html>
<html>
<head>
<title>One Page Layout & Fixed Side Nav</title>
<link rel="stylesheet" type="text/css" href="style/style.css">
<script type="text/javascript" src="js/jquery-3.2.1.js"></script>
<script type="text/javascript" src="js/jquery.scrollto.js"></script>
<script type="text/javascript" src="js/scroll.js"></script>
</head>
<body>
<div id="wrapper">
<div id="header">
<h1>One Page Layout & Fixed Side Nav</h1>
</div><!-- end of header -->
<div id="nav-anchor"></div>
<div id="content">
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#gallery">Gallery</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
<div class="c-article">
<section id="home">
<h2>Home</h2>
<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.</p>
</section>
<section id="about">
<h2>About</h2>
<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.</p>
</section>
<section id="gallery">
<h2>Gallery</h2>
<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.</p>
</section>
<section id="contact">
<h2>Contact</h2>
<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.</p>
</section>
</div>
</div><!-- end of content -->
<div id="footer">
<p>Hak Cipta © 2017 | <a class="fot-brand" href="http://www.yellowweb.id/blog" target="_blank">YELLOWWEB.ID</a></p>
</div><!-- end of footer -->
</div><!-- end of wrapper -->
</body>
</html>
Yang perlu kita perhatikan adalah source yang menuju ke file javascript
<script type="text/javascript" src="js/jquery-3.2.1.js"></script> <script type="text/javascript" src="js/jquery.scrollto.js"></script> <script type="text/javascript" src="js/scroll.js"></script>
terdapat beberapa file javascript, seperti library utama, serta dua plugin lainnya sebagai efek scroll serta aktivasinya.
Jangan lupa untuk menambahkan kode berikut ini:
<div id="nav-anchor"></div>
berguna ketika halaman discroll.
Untuk lebih jelasnya hasilnya bisa dilihat dibawah ini, dan silahkan berkreasi sampai jumpa diartikel berikutnya.