`//My HTML code
<div>
<div className="picbot">PicBot</div>
<ul className="navbarlist">
<li>Overview</li>`your text`
<li>Examples</li>
<li>Tour</li>
<li>Blog</li>
<li>Help</li>
</ul>
<button className="download">Download</button>
</div>`
// My CSS code
.navbarlist {
list-style: none;
display: inline-flex;
flex-direction: row;
color: rgb(192, 190, 190);
font-size: 18px;
font-weight: 600;
justify-content: space-between;
}
I applied the justify content: space between on the ul tag with className of .navbarlist expected the items on the list to space out evenly but they don’t (I use className instead of class in the html because it is written in jsx)
2
Answers
They are spaced evenly, there’s just no additional space for them to occupy. So they evenly have no space in between them. Inline elements (including
inline-flex
) don’t automatically expand to the width of their containers.You can make the entire
<ul>
take up the width of its container by changinginline-flex
toflex
, for example:You didn’t add width to your div (.navbarlist) and in this way, the div doesn’t expand and add gaps between items as expected. Try to add width and see if that will help.
Also, there is a different solution for this. You can simply change
inline-flex
toflex
. This way you don’t necessarily need to addwidth
.