xxxxxxxxxx
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
.topnav {
overflow: hidden;
background-color: #333;
}
.topnav a {
float: left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background-color: #ddd;
color: black;
}
.topnav a.active {
background-color: #4CAF50;
color: white;
}
</style>
</head>
<body>
<div class="topnav">
<a class="active" href="#home">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
</div>
<div style="padding-left:16px">
<h2>Top Navigation Example</h2>
<p>Some content..</p>
</div>
</body>
</html>
xxxxxxxxxx
<!--HTML CODE-->
<nav>
<a href="#">About us</a>
<a href="#">Photos</a>
<a href="#">Travel</a>
<a href="#">Shop</a>
<a href="#">Reviews</a>
<a href="#">Seminars</a>
<a href="#">Events</a>
</nav>
/*CSS: Horizontal title bar*/
nav {
padding: 0;
margin-bottom: 9px;
text-align: center;
}
nav a {
display: inline-block;
color: white;
text-decoration: none;
background-color: mediumslateblue;
border: 2px solid black;
border-radius: 10px 10px 0 0;
border-bottom: 0;
padding: 10px 14px 8px 14px;
font-size: 17px;
margin-right: 40px;
}
/*to create a vertical bar when the width reaches 599px*/
@media screen and (max-width: 599px) {
nav a{
display: block;
}
}
/*just to decrease the margin-right when it reaches min and max width of 600px and 899px respectively*/
@media screen and (min-width: 600px) and (max-width: 899px) {
nav a{
margin-right: 30px;
}
}