Jul 30, 2025
The lecture explains the CSS repeat() function, which simplifies defining repeating columns or rows in grid layouts, and details its syntax, usage forms, and rules.
repeat() function creates recurring column or row patterns in CSS Grid layouts using compact syntax.grid-template-columns and grid-template-rows properties.repeat(count, tracks), e.g., repeat(2, 60px).auto-fill, or auto-fit.60px, 1fr, minmax(), or a sequence like 20px 1fr.[col-start] 60px [col-end].
auto-fill or auto-fit for repeat count, must use .40px), percent, or minmax() with length/percentage.fr units to distribute remaining space, e.g., 1fr.fr, min-content, max-content, auto, minmax(), or fit-content().auto-fill: Repeats tracks as many times as fits in the container, creating empty tracks if needed.auto-fit: Like auto-fill, but collapses empty tracks to 0px after placing items.min-content / max-content: These set the track size based on minimum/maximum content contributions.auto: As minimum, uses the largest minimum size of items; as maximum, same as max-content.grid-template-columns: repeat(2, 60px); creates two 60px columns.grid-template-columns: repeat(auto-fill, 40px); fills the row with as many 40px columns as will fit.grid-template-columns: repeat(2, 20px 1fr); creates two sets of a 20px and a flexible column.repeat() with grid-template-columns and grid-template-rows.auto-fill and auto-fit.repeat() in code examples to understand various forms and restrictions.