Percentages and fr units in CSS grids
Also, along with fr, you can use values in %, which also determine what part of the container the column will occupy. In this case, the column size in % will be calculated first, and the remaining free space will be divided into fractions:
<div id="parent">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
</div>
#parent {
display: grid;
grid-template-columns: 50% 1fr 2fr 30%;
border: 2px solid #696989;
padding: 10px;
width: 600px;
}
#parent > div {
padding: 10px;
border: 1px solid #696989;
}
:
Let's say you have three columns in your grid. Make the first column 20%, and make the other two columns the same size.
Let's say your grid has five columns. Make the first column 100px, the second column 20%, and the rest of the columns divide the remaining space so that each column is twice the size of the previous one.