ul {
display: grid;
width: 260px;
grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
grid-auto-rows: 1fr;
grid-gap: 10px;
list-style-type: none;
border: 2px solid black;
box-sizing: border-box;
margin: 0;
padding: 0;
background: gray;
}
li {
width: 40px;
height: 40px;
}
<ul class="palette">
<li style="background-color: rgb(0, 0, 255);"></li>
<li style="background-color: rgb(51, 51, 51);"></li>
<li style="background-color: rgb(203, 58, 135);"></li>
<li style="background-color: rgb(237, 106, 90);"></li>
<li style="background-color: rgb(155, 193, 188);"></li>
<li style="background-color: rgb(255, 247, 174);"></li>
<li style="background-color: rgb(184, 51, 106);"></li>
<li style="background-color: rgb(61, 44, 46);"></li>
<li style="background-color: rgb(105, 173, 212);"></li>
<li style="background-color: rgb(245, 223, 22);"></li>
<li style="background-color: rgb(252, 186, 86);"></li>
<li style="background-color: rgb(0, 185, 252);"></li>
<li style="background-color: rgb(181, 141, 182);"></li>
<li style="background-color: rgb(58, 50, 96);"></li>
</ul>
See Question&Answers more detail:
os