Skip to content

Instantly share code, notes, and snippets.

@Allwin12
Last active October 25, 2019 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Allwin12/e253a2399de00e540ea3e156c34dbc0c to your computer and use it in GitHub Desktop.
Save Allwin12/e253a2399de00e540ea3e156c34dbc0c to your computer and use it in GitHub Desktop.
The navigation bar used in the website - https://www.codesimple.info/
<!doctype html>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<style>
body {margin:0;font-family:Arial}
.topnav {
overflow: hidden;
background-color: #333;
}
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.active {
background-color: #4CAF50;
color: white;
}
.topnav .icon {
display: none;
}
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 17px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.topnav a:hover, .dropdown:hover .dropbtn {
background-color: #555;
color: white;
}
.dropdown-content a:hover {
background-color: #ddd;
color: black;
}
.dropdown:hover .dropdown-content {
display: block;
}
@media screen and (max-width: 600px) {
.topnav a:not(:first-child), .dropdown .dropbtn {
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;
}
.topnav.responsive .dropdown {float: none;}
.topnav.responsive .dropdown-content {position: relative;}
.topnav.responsive .dropdown .dropbtn {
display: block;
width: 100%;
text-align: left;
}
}
</style>
<div class="topnav" id="myTopnav">
<a href="http://www.codesimple.info/" id="homeButton" >Home</a>
<div class="dropdown">
<button class="dropbtn">Topics
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a href="#">C</a>
<a href="#">C++</a>
<a href="#">Python</a>
</div>
</div>
<a href="">Django</a>
<a id="blogButton" href="http://www.codesimple.info/search/label/post">Blog</a>
<a id="aboutButton" href="http://www.codesimple.info/p/about.html" onclick="aboutClick()" id="navbarAbout">About</a>
<a id="contactButton" href="https://www.codesimple.info/p/contact.html">Contact</a>
<a href="javascript:void(0);" style="font-size:15px;" class="icon" onclick="myFunction()">&#9776;</a>
</div>
<script>
current_url = window.location.href;
color = " #3364ff ";
if (current_url=="https://www.codesimple.info/")
{
document.getElementById("homeButton").style.background=color;
}
else if(current_url=="https://www.codesimple.info/p/contact.html")
{
document.getElementById("contactButton").style.background=color;
}
else if(current_url=="https://www.codesimple.info/p/about.html")
{
document.getElementById("aboutButton").style.background=color;
}
else if(current_url=="https://www.codesimple.info/search/label/post")
{
document.getElementById("blogButton").style.background=color;
}
</script>
</!doctype>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment