I am struggling with the following, could you please help?
I want the logos to be aligned next to each other to the left and the links aligned next to each other to the :
[Logo1] [Logo2] [Logo3] (spaceeeeeeeeeeeeeeeeeeee) [Link1] [Link2] [Link3]nav{
width: 100%;
position: absolute;
top: 0;
left: 0;
padding: 20px 8%;
display: flex;
align-items: center;
justify-content: space-between;
}
nav .logo{
width: 40px;
}
nav ul li{
list-style: none;
display: inline-block;
margin-left: 40px;
}
nav ul li a{
text-decoration: none;
color: #fff;
font-size: 17px;
}
<nav>
<img src="images/Logo1.svg" class="logo">
<img src="images/Logo2.svg" class="logo">
<img src="images/Logo3.svg" class="logo">
<ul>
<li><a href="#">Link1</a></li>
<li><a href="#">Link2</a></li>
<li><a href="#">Link3</a></li>
</ul>
</nav>
I tried changing attributes under nav .logo but was not successfull (e.g. dispay and position)
2
Answers
I think the code snippet I have attached below should work. I did change your code up a bit (changes not related to the solution) to include a placeholder image and make the link colors black so you could see how everything looks.
First, I grouped your logos and your links into two separate divs. Since your
nav
has the propertiesdisplay: flex
andjustify-content: space-between
, it was causing all of your elements innav
to be evenly distributed in the line. By grouping the logos and links into two separate divs, the property evenly distributed the two groups instead of every element.Next, I changed your
margin-left
property innav ul li
from40px
to10px
. This change helps make the spacing between your links much smaller. To simulate the same spacing for your logos, I added the propertymargin-right: 10px
to thenav .logo
selector. Hopefully this helps!