right now Im working on the odin project trying to build a landing page.
My navbar stays on the left side although I want it to be on the right side.
This is my code:
.container{
width:100%;
height:27vh;
background-color: #1f2937;
position:static;
}
.footer{
position: fixed;
bottom: 0px;
width: 100%;
height: 10vh;
background-color:#1f2937;
color: white;
text-align: center;
justify-content: center;
display: flex;
}
.headerlogo {
font-size: 20px;
font-family: 'Times New Roman', Times, serif;
}
.navbar {
position: fixed;
width: 85%;
margin: auto;
padding: 35px 0;
display: flex;
align-items: center;
justify-content: space-between;
top: -30px;
flex-direction: row;
}
.navbar ul li {
list-style: none;
display: inline-block;
margin: 0 20px;
color:white;
text-decoration: none;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Website</title>
<link href="style.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="navbar">
<ul>
<li><a href="index.html">header link one</a></li>
<li><a href="index.html">header link two</a></li>
<li><a href="index.html">header link three</a></li>
</ul>
</div>
</div>
<div class="footer">
Copyright © The Odin Project 2021
</div>
</body>
</html>
Ive tried using justify content:space between to get the navbar to the right side and have been sitting on this problem for hours but i cant find a solution, perhaps someone can help me out.
3
Answers
I propose two alternatives
The code would be like this:
The code would be like this:
I hope this helps you!
If you want to move the items to the right just do this:
I changed to
justify-content: space-between;
tojustify-content: flex-end;
if you want the item to move to the very right just set the navbar width to 100%:
Like this:
Here is the solution: