I have created a nav-bar but I want to place it at the top right of the page, in line with the logo, how can I do this? This is how it looks at the moment:
My HTML is:
<nav id="nav-bar" >
<ul>
<li><a class="features" href="#features"> Features </a></li>
<li><a class="how-it-works" href="#how-it-works"> How it works </a></li>
<li><a class="pricing" href="#pricing"> Pricing </a></li>
</ul>
</nav>
And my CSS:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html,
body {
background-color: #F2F2F2;
font-family: 'Lato', sans-serif;
}
li {
list-style: none;
}
a {
color: #000;
text-decoration: none;
display: block;
text-align: right;
}
header {
padding: 10px;
}
Here’s a link to the code pen I’ve written all the code in: https://codepen.io/marta2804/pen/vYBWKvW?editors=1100
Are you aware with flexbox?
Yes I am but what do I type to move it?
If I understand you correct, then your header
element should look like:
header {
padding: 10px;
display: flex;
justify-content: space-between;
}
Let me know if you need more explanations.
2 Likes
That was very helpful, thank you! Now it looks like this:
Do you know how I can make it look like this:
The display
property of li
elements should be equal to inline-block
.
Try to set it up.
To get your list items as the second picture use display Inline-block.
li {
list-style: none;
display: inline-block;
}
1 Like
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
html,
body {
background-color: #F2F2F2;
font-family: 'Lato', sans-serif;
}
img {
max-width:300px;
margin: 10px;
position: relative;
}
li {
list-style: none;
display: inline-block;
padding: 10px ;;
}
a {
color: #000;
text-decoration: none;
}
header {
padding: 10px;
display: flex;
justify-content: space-between;
}
This styles are giving expected output. You can try this
1 Like