1

I have a flex ul with three li. The first and last li have contents of unknown and possibly differing length. The middle li should have its contents centered in the middle of the ul.

enter image description here

Is there any way to accomplish this with pure HTML/CSS?

ul {
  display: flex;
  width: 250px;
  padding: 0;
}

li {
  margin: 0;
  padding: 0;
  list-style-type: none;
  white-space: nowrap;
  border: 1px solid blue;
}

li:first-of-type {
  flex: 0;
}

li:not(:first-of-type):not(:last-of-type) {
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

li:last-of-type {
  flex: 0;
  text-align: right;
}
  
  <ul>
    <li>Some Options</li>
    <li>Some long Title</li>
    <li>Done</li>
  </ul>
Tonald Drump
  • 1,227
  • 1
  • 19
  • 32
  • This question is not a duplicate of [Keep the middle item centered…](https://stackoverflow.com/questions/32378953/keep-the-middle-item-centered-when-side-items-have-different-widths). The image the asker posted shows that the three `li` items don’t have to be of equal width. – Lypyrhythm Jul 21 '19 at 15:37
  • @DavidThomas yes, only three. It's like the menu at the top of an iOS Screen. – Tonald Drump Jul 21 '19 at 16:49