I am trying to create a nav bar. I added a logo in the top left of the nav bar and links "Home", "Contacts", and "Products" in the top right.
I am trying to put :hover on the logo link with padding: 9px 12px and I get a problem with it.
When the cursor is over the logo, then the hover moves the whole navigation bar about 3px.
I tried to make the nav bar and links bigger, but then it does not look good.
Here is my code:
a{
text-decoration: none;
}
nav {
display: flex;
justify-content: space-between;
align-items: center;
background-color: rgb(144, 144, 144);
padding: 10px 20px;
}
.nav__logo {
background-color: rgb(208, 208, 208);
padding: 7px 9px;
border-radius: 40px;
}
.nav__logo a {
font-size: 28px;
font-family: 'Great Vibes', cursive;
}
.nav__logo:hover {
background-color: rgb(176, 176, 176);
padding: 9px 12px;
}
.nav__logo-text {
margin: 0;
font-weight: 500;
font-size: 23px;
}
.nav__single-link {
padding: 18px;
margin: 0;
font-family: 'Oswald', sans-serif;
font-weight: 500;
font-size: 17px;
}
.nav__single-link:hover {
background-color: rgb(208, 208, 208);
border-radius: 12px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Great+Vibes&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Oswald:wght@200;300;400;500&display=swap" rel="stylesheet">
</head>
<body>
<nav>
<div class="nav__logo">
<a class="nav__logo-text" href="./index.html">CampHouse</a>
</div>
<div class="nav__links">
<a class="nav__single-link" href="./index.html">Home</a>
<a class="nav__single-link" href="./products.html">Products</a>
<a class="nav__single-link" href="./contact.html">Contact Us</a>
</div>
</nav>
</body>
</html>