I have been working on creating a fixed menu using flexbox. Within my navigation bar, I have set up 2 divs. The first one is supposed to contain the logo, and the second one is for the menu (utilizing the display:flex
property). However, I am facing an issue when trying to position the list elements (li
) in my menu. I aim to have a horizontal menu, but when I apply justify-content:space-between
, the first element should align with the left edge of the menu's div, yet it has a slight margin that I cannot seem to resolve.
https://jsfiddle.net/4Lmu08yc/
header {
height:100vh;
background-color:yellow;
width:100vw;
max-width:100%;
}
.navbar {
width:100vw;
background-color:grey;
height:7vh;
max-width:100%;
position:fixed;
border-bottom:5px solid white;
z-index:2;
}
.flex_row {
display:flex;
flex-direction:row;
}
.container{
height:100%;
width:100vw;
max-width:100%;
background-color:green;
display:flex;
}
#logo {
height:100%;
background-color:white;
flex-grow:1;
}
#menu {
height:100%;
background-color:yellow;
flex-grow:1;
}
#menu ul {
list-style-type:none;
justify-content:flex-start;
align-content:flex-end;
}
#menu ul li {
border:1px solid black;
line-height:40px;
}
<header>
<div class="container">
<div class="navbar flex_row">
<div id ="logo"></div>
<div id ="menu">
<ul class="flex_row">
<li><a href="#">text1</a></li>
<li><a href="#">text2</a></li>
<li><a href="#">text3</a></li>
<li><a href="#">text4</a></li>
</ul>
</div>
</div>
</div>
</header>