<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
position: sticky;
width:100%;
top:0;
margin: 0;
padding: 0px;
overflow: hidden;
background-color: lightgray;
}
li {
float: left;
border-right: 1px solid blue;
}
li a {
display: block;
color: blue;
font-size:20px;
text-align: center;
padding: 10px 20px;
text-decoration: none;
}
.active{
background-color: gray;
color: white;
}
li a:hover {
background-color: orange;
color: white;
}
</style>
</head>
<body>
<h1> Contoh dari sticky menu navigasi</h1>
<ul>
<li><a class="active" href="#home">Beranda</a></li>
<li><a href="#">Java</a></li>
<li><a href="#">HTML</a></li>
<li><a href="#">CSS</a></li>
</ul>
<h1 style="padding-top: 100px; text-align: center;">Halo Dunia </h1>
<h2 style="padding-bottom: 2000px; text-align: center;"> Gulir ke bawah halaman untuk melihat menu sticky navigasi</h2>
</body>
</html>
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.