Here is the HTML and CSS code snippet:
body {
background-color: green;
}
.navbar {
overflow: hidden;
background-color: #333;
text-align: center;
width: 100%;
}
.navbar a {
float: left;
font-size: 18px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 18px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.navefix:hover, .dropdown:hover, .dropbtn {
background-color: red;
cursor: pointer;
}
.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;
}
.dropdown-content a:hover {
background-color: #ddd;
}
.dropdown:hover .dropdown-content {
display: block;
}
<body>
<div class="navbar">
<a></a>
<div class="dropdown">
<button class="dropbtn" onclick="location.href='index.html'">Index
</button>
<div class="dropdown-content">
<a href="page1.html">page1</a>
<a href="page2.html">page2</a>
<a href="page3.html">page3</a>
</div>
</div>
<a href="page4.html" class="navefix">page4</a>
</div>
</body>
In the provided code snippet, you may notice that the navbar is supposed to extend beyond the window so there is no gap between it and the edges of the page.