I am trying to distribute elements with equal spacing in between while keeping the first and last items left- and right-aligned.
I believe flex-based layouts have an easy solution for it but I want to support older browsers, too.
I have already made a JS-based solution which I will be posting but feel free to suggest better solutions & if it's possible via only CSS.
Here is a fiddle.
ul {
position: relative;
margin: 0;
font-size: 0;
padding: 0;
display: table;
width: 100%;
list-style: none;
}
ul:after {
content: '';
display: block;
position: absolute;
top: 50%;
background: #000;
left: 0;
height: 1px;
width: 100%;
z-index: -1;
}
li {
display: table-cell;
text-align: center;
}
li:first-child {
text-align: left;
}
li:last-child {
text-align: right;
}
span {
font-family: sans-serif;
display: inline-block;
font-size: 15px;
line-height: 1em;
color: #fff;
background: #000;
padding: 6px 9.34px;
border-radius: 999px;
}
<ul>
<li><span>1</span></li>
<li><span>2</span></li>
<li><span>3</span></li>
<li><span>4</span></li>
<li><span>5</span></li>
</ul>