How to set width dependent on the number of elements contained in the parent?

Here in ul 2 surpluses, how to make the width li was 50%. And if the odd 4 - 25%?
<ul class="slick-dots" style="" role="tablist">
 <li class="" role="presentation">
 <button type="button" role="tab" id="slick-slide-control00" aria-controls="slick-slide00" aria-label="1 of 2" 
tabindex="-1">1</button>
</li>
 <li role="presentation" class="slick-active">
 <button type="button" role="tab" id="slick-slide-control01" aria-controls="slick-slide04" aria-label="2 of 2" tabindex="-1">2</button>
</li>
</ul>
April 19th 20 at 12:16
1 answer
April 19th 20 at 12:18

Find more questions by tags jQueryCSS