At the last row, the spaces among li elements are not same as the previous rows. I want all of them to be same. I do not want to use text-align: center, because it ruins the alignment between the li elements at the last row and the li elements at the upper rows. My code is:
<body>
<ul>
<li><img src="http://placehold.it/120x90" alt="stack"></li>
<li><img src="http://placehold.it/120x90" alt="stack"></li>
<li><img src="http://placehold.it/120x90" alt="stack"></li>
<li><img src="http://placehold.it/120x90" alt="stack"></li>
<li><img src="http://placehold.it/120x90" alt="stack"></li>
<li><img src="http://placehold.it/120x90" alt="stack"></li>
<li><img src="http://placehold.it/120x90" alt="stack"></li>
<li><img src="http://placehold.it/120x90" alt="stack"></li>
<li><img src="http://placehold.it/120x90" alt="stack"></li>
<li><img src="http://placehold.it/120x90" alt="stack"></li>
<li><img src="http://placehold.it/120x90" alt="stack"></li>
</ul>
</body>
ul {
list-style-type: none;
padding: 0;
text-align: justify;
}
li {
margin-left: 6px;
margin-right: 6px;
margin-bottom: 10px;
direction: ltr;
width: 300px;
display: inline-block;
text-align: center;
}
2
Answers
I've found the answer:
Worked perfectly fine. Thanks a lot for inspiration.
You could use grid instead of setting inline-blocks and justifying.
(I switched to using placeholder.com as the original image took time to load).