I read that percentage values calculate according to the nearest block container's width, so why are my li
elements overflowing and how do I fix it so I can use the percentage values for responsiveness.
*{
margin:0;
padding:0;
box-sizing:border-box;
}
body{
background-color:yellow;
width:100%;
height:100vh;
}
li{
margin: 0 10% 0 0;
font-size:20px;
color:black;
font-weight:bold;
}
#logo{
font-size: 40px;
height:100%;
display:flex;
align-items:center;
}
.navigation{
width:100%;
height:70px;
display:flex;
align-items:center;
justify-content:space-between;
}
#list-items{
display:flex;
list-style-type:none;
}
<nav class="navigation">
<div id="logo">Ba-nna</div>
<ul id="list-items">
<li>Food</li>
<li>Events</li>
<li>About</li>
<li>Fun</li>
<li>Merch</li>
</ul>
</nav>
This code causes scroll bars to appear.
Note: If I use px
it works ,but there has to be another way to create spacing.
To properly view code view, view it in another window in full browser screen.
I expected the li
will form a space between themselves and also a space between the last li
and the ul
.