I have an element uland 5 children <li>.
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<ul>has a property display: flex. I tried using the calc property in <li>to evenly distribute list items:
calc:(100% / 5);
This gives the desired result and evenly distributes blocks 5 <li>
Now I have added borders to the right of all, but the last child <li>. Therefore, I reduced the total width of all borders combined from the total width <ul>.
calc:((100% - 8px) / 5);
It also worked correctly and uniformly in the size of blocks <li>with borders.
ul {
width: 600px;
height: 300px;
margin: 0;
padding: 0;
display: flex;
background: red;
}
li {
list-style: none;
display: block;
width: calc((100% - 0.8px) / 5);
height: 100%;
border-right: 0.2px solid black;
background: blue;
}
li:last-child {
border-right: none;
}
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
Run codeHide resultNow I tried to set the border width in the viewer vwinstead of px, but it gives a different result.
ul {
width: 600px;
height: 300px;
margin: 0;
padding: 0;
display: flex;
background: red;
}
li {
list-style: none;
display: block;
width: calc((100% - 0.8vw) / 5);
height: 100%;
border-right: 0.2vw solid black;
background: blue;
}
li:last-child {
border-right: none;
}
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
Run codeHide result, . ( ). , vw flexbox .
?
EDIT:
, , . , . calc , , , calc ( ). "calc" fix.