Struggling with my HTML and CSS - I'm trying to create a navbar. HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>My Website</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<div class="nav">
<a href="#" class="nav-title">Website</a>
<nav>
<ul>
<li><a href="#" class="nav-link">Home</a></li>
</ul>
</nav>
</div>
<h1>Heading</h1>
</body>
</html>
CSS:
@import url('https://fonts.googleapis.com/css?family=Roboto:400,700');
body {margin: 0; font-family: 'Roboto', sans-serif;}
.nav-title {
float: left;
color: rgb(114, 114, 114);
text-decoration: none;
padding: 1rem 1rem 1rem 1rem;
}
nav {
float: right;
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 70px;
position: relative;
padding: 1rem 1rem 1rem 1rem;
}
nav li a {
padding: 5px 5px 5px 5px;
color: rgb(114, 114, 114);
text-decoration: none;
background-color: rgb(230, 230, 230);
border-radius: 3px;
}
.title {
margin: 0;
text-align: center;
color: rgb(114, 114, 114);
font-size: 3em;
padding-top: 2vh;
}
But when I add an h1 tag below the div with the nav
class, it messes things up.
Screenshot Here
What am I missing?