我有五个按钮。我希望他们占据其父 div 的可用宽度,每个 div 的大小相同:
<div style="width: 100%; background-color: red;">
<button type="button" style="width: 20%;">A</button>
<button type="button" style="width: 20%;">B</button>
<button type="button" style="width: 20%;">C</button>
<button type="button" style="width: 20%;">D</button>
<button type="button" style="width: 20%;">E</button>
</div>
有没有一种方法可以做到这一点,而无需手动确定它们每个都需要 20% 的宽度?我想在运行时删除一个按钮,这意味着我必须再次将每个剩余的按钮更新为 width=25%。
我只是在检查是否有更自动化的方法。