HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Make a 4 columns grid container
The grid-template-columns
property specifies the number
(and the widths) of columns in a grid
layout.
The values are a space separated list, where each value specifies the size of the respective column.
Default value: | none |
---|---|
Inherited: | no |
Animatable: | yes. Read about animatable Try it |
Version: | CSS Grid Layout Module Level 1 |
JavaScript syntax: | object.style.gridTemplateColumns="50px 50px 50px" Try it |
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
grid-template-columns | 57 | 16 | 52 | 10 | 44 |
Value | Description | Demo |
---|---|---|
none | Default value. Columns are created if needed | Demo ❯ |
auto | The size of the columns is determined by the size of the container and on the size of the content of the items in the column | Demo ❯ |
max-content | Sets the size of each column to depend on the largest item in the column | Demo ❯ |
min-content | Sets the size of each column to depend on the smallest item in the column | |
length | Sets the size of the columns, by using a legal length value. Read about length units | Demo ❯ |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
Make a 4 columns grid container, and specify a size for each column:
.grid-container {
display: grid;
grid-template-columns:
30px 200px auto 100px;
}
CSS Tutorial: CSS Grid Layout
CSS Reference: The grid-template-rows property
CSS Reference: The grid-template property