Is it possible to make all list items equally wide according to list's widest item? See the fiddle:
https://jsfiddle.net/82m71ztw/2/
<ol class="progress">
<li class="active">First step: Choose</li>
<li>Step two</li>
<li>Three</li>
</ol>
Is it possible to make all list items equally wide according to list's widest item? See the fiddle:
https://jsfiddle.net/82m71ztw/2/
<ol class="progress">
<li class="active">First step: Choose</li>
<li>Step two</li>
<li>Three</li>
</ol>
Use JavaScript to calculate width of each list, add them to an array, select max value and assign it to each list. The following code is tested and works great:
var lists = document.querySelectorAll(".progress li");
var arrayList = [];
for (var i = 0; i < lists.length; i++) {
var eachList = lists[i].offsetWidth;
arrayList.push(eachList);
var MaxWidth = Math.max.apply(null, arrayList);
lists[i].style.width = MaxWidth +"px";
}
Here is a jsFiddle: https://jsfiddle.net/rowin_aria/2szow6rb/2/
its not css, however few lines of JS will save you scratching your head plus this gives you an accurate result
Shah's solution didn't quite do it for me. Each width was set to that of the widest element above it. I changed his code to make two loops. The first gathers all the widths and the second sets the width of each element to that of the widest one.
var lists = document.querySelectorAll(".progress li");
var arrayList = [];
for (var i = 0; i < lists.length; i++) {
var eachList = lists[i].offsetWidth;
arrayList.push(eachList);
}
var MaxWidth = Math.max.apply(null, arrayList);
for (var i = 0; i < lists.length; i++) {
lists[i].style.width = MaxWidth +"px";
}
In your css just add a fixed width, depending on the largest li element.`
li {
list-style-type: none;
counter-increment: item;
width: 163px;
.....`
You could use a flexbox for the list and let the items grow. See https://jsfiddle.net/82m71ztw/75/