What does the grid-template-columns property do?
grid-template-columns sets the structure of columns in CSS Grid, defining how many there will be and the size of each one.
Examples:
css
.container {
display: grid;
grid-template-columns: 200px 1fr 1fr;
}This creates a grid of three columns: the first is fixed (200px), the other two are flexible, one fraction (fr) each.
Allowed column values:
px,em,rem: fixed units%: relative sizesfr: fractions of free spaceauto: size based on contentmin-content,max-content,minmax(): auto-calculationsrepeat(): repeating columns, for example:
css
grid-template-columns: repeat(3, 1fr); /* three equal columns */Summary: the property controls the number and width of columns in a grid container.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.