最終的にいくつになるかわからない場合は、次のli
トリックを使用できます。
li:nth-child(1):nth-last-child(1) {width: 100%;}
li:nth-child(1):nth-last-child(2),
li:nth-child(1):nth-last-child(2)~ li {width: 50%;}
li:nth-child(1):nth-last-child(3),
li:nth-child(1):nth-last-child(3)~ li {width: 33.3333%;}
li:nth-child(1):nth-last-child(4),
li:nth-child(1):nth-last-child(4)~ li {width: 25%;}
li:nth-child(1):nth-last-child(5),
li:nth-child(1):nth-last-child(5)~ li {width: 20%;}
より大きな数に対してそれがどのように続くかがわかります...
これは思い出せないブログから盗んだものです。これは、私がこれまでに見た中で最も賢いアプローチです。
それは私がCSSについてほとんど知らないことを示しています:)