It appears that the spacing in the markup is causing issues because the elements are set to display as inline-level blocks.
ul {
background: yellow;
color: black;
/* To avoid the spaces, remove the font size from the parent element */
font-size: 0;
}
ul li {
width: calc(100% / 3);
display: inline-block;
text-align: center;
/* Resetting the font size on individual elements */
font-size: 16px;
}
<ul>
<li>hello</li>
<li>ciao</li>
<li>goodbye</li>
</ul>
You can also eliminate the extra space within the HTML structure.
ul {
background: yellow;
color: black;
}
ul li {
width: calc(100% / 3);
display: inline-block;
text-align: center;
}
<ul>
<li>hello</li><li>ciao</li><li>goodbye</li>
</ul>
Another approach to address this issue would be:
ul {
background: yellow;
color: black;
}
ul li {
width: calc(100% / 3);
display: inline-block;
text-align: center;
}
<ul>
<li>hello</li><!--
---><li>ciao</li><!--
---><li>goodbye</li>
</ul>