JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">
<div class="topnav" id="myTopnav">
<div class="topnav-left">
<a href="/"><img src="Img/Signature-Black.png"></a>
</div>
<a href="./contact.html">Contact</a>
<a href="./about.html"> About</a>
<div class="dropdown">
<button class="dropbtn">Blog <i class="fa fa-caret-down"></i></button>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
</div>
</div>
<a href="./photos.html">Photos</a>
<a href="javascript:void(0);" class="icon" onclick="myFunction()">
<i class="fa fa-bars"></i>
</a>
</div>
CSS
.topnav {
overflow: hidden;
background-color: blue;
z-index: 100;
align-items: center;
top: 0;
left: 0;
width: 100%;
padding: 30px 10%;
}
.topnav a {
float: right;
color: black;
text-align: center;
padding: 10px 20px;
text-decoration: none;
font-size: 18px;
font-weight: 500;
margin-right: 35px;
}
.topnav a:hover {
color: #ffffff;
transition: 1s;
}
.topnav .icon {
display: none;
}
.topnav .icon:hover {
color: #daa520;
}
.topnav-left {
float: left;
}
/* Dropdown */
.dropdown {
float: right;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 18px;
font-weight: 500;
border: none;
outline: none;
color: rgb(0, 0, 0);
padding: 10px 20px;
background-color: inherit;
font-family: inherit;
margin-right: 35px;
}
.topnav a:hover,
.dropdown:hover .dropbtn {
color: rgb(255, 255, 255);
transition: 1s;
}
.dropdown-content {
display: none;
position: absolute;
background-color: transparent;
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;
}
.dropdown-content a:hover {
color: #ffffff;
}
.dropdown:hover .dropdown-content {
display: block;
}
/* Resize Screen */
@media screen and (max-width: 900px) {
.topnav a:not(:first-child),
.dropdown .dropbtn {
display: none;
}
.topnav a.icon {
float: right;
display: block;
}
.topnav-left {
float: left;
}
}
@media screen and (max-width: 900px) {
.topnav.responsive {
position: relative;
}
.topnav .icon {
position: fixed;
right: 7%;
top: 30px;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
.topnav.responsive .topnav-left {
float: none;
}
.topnav.responsive .dropdown {
float: none;
}
.topnav.responsive .dropdown-content {
position: relative;
}
...
JavaScript
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}