I have a fieldset containing multiple buttons with the same fixed width. In a row/line it should fit as many buttons as possible. However during the linebreak it will cause a big white-space.
I tried display: flex;
in combination with flex-wrap
. However the white-space remains or the box overflows
Also I tried css-grid by using grid-template-columns: repeat(auto-fit, minmax(10em, 1fr));
which doesn't work either.
Anybody else with an idea how to size either size the box to the content to not leave a white-space or to size the buttons to fill up all the space without breaking the box max-width and fit as many as possible?
I know why the white space there, but I can't figure out how to remove it. I'm aware that it possibly requires Javascript. However related questions on SO mentioned this aswell but where unable to eleborate a Javascript solution to be understandable/reproduciable.
div {
max-width: 80%;
}
button{
width: 10em;
}
<div>
<fieldset>
<legend>Color</legend>
<button>1</button>
<button>2</button>
<button>3</button>
<button>4</button>
<button>5</button>
<button>6</button>
<button>7</button>
<button>8</button>
<button>9</button>
</fieldset>
</div>