Skip to content

Instantly share code, notes, and snippets.

@jasonleow
Created October 15, 2020 02:59
Show Gist options
  • Save jasonleow/23ec55778912943bad5656103907b765 to your computer and use it in GitHub Desktop.
Save jasonleow/23ec55778912943bad5656103907b765 to your computer and use it in GitHub Desktop.
Top navbar
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
@import url("https://fonts.googleapis.com/css?family=Assistant:400,400i,700");
body {
margin: 0;
font-family: 'Assistant', sans-serif;
background-color: ;
}
.topnav {
display: block;
width: 100%;
text-align: center;
overflow: hidden;
background-color: transparent;
}
.topnav a {
float: center;
display: inline-block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background-color: #96D3FF;
color: black;
}
.topnav a.active {
background-color: #FF9900;
color: white;
}
.topnav .icon {
display: none;
}
@media screen and (max-width: 600px) {
.topnav a:first-child,
a:not(:first-child) {
display: none;
}
.topnav a.icon {
float: right;
display: block;
}
}
@media screen and (max-width: 600px) {
.topnav.responsive {
position: relative;
}
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
}
</style>
</head>
<body>
<div class="topnav" id="myTopnav">
<a href="/#home">Home</a>
<a href="/#about">About</a>
<a href="/#theprocess">Process</a>
<a href="/#pricing">Pricing</a>
<a href="/#faq">FAQs</a>
<a href="/#demosites">Demos</a>
<a href="/#contact">Contact</a>
<a href="javascript:void(0);" class="icon" onclick="myFunction()">
<i class="fa fa-bars"></i>
</a>
</div>
<script>
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment