grid containerė grid-template-areasëĨž ė§ė íęģ grid itemė grid-areaëĨž ëķėŽíë ëė
grid itemė grid-column-start(end)
ė grid-row-start(end)
ëĨž ėŽėĐí ėë ėëĪ.
íėė ęē―ė° grid containerė gap íëĄíží°
ëĨž ėŽėĐíīė ėíë ëŠĻėė ë ėīėėė ë ė―ęē ë§ëĪ ė ėëĪ.
ëŽžëĄ ė ėė ęē―ė°ėë gap íëĄíží°ëĨž ėŽėĐí ė ėė§ë§ ėíë ëŠĻėė ë ėīėėė ë§ëĪęļ°ė íėę° ë ė―ëĪ.
<div class="grid">
<div class="header"></div>
<div class="content"></div>
<div class="nav"></div>
<div class="footer"></div>
</div>
ėĢžė ėēëĶŽë ëķëķėī grid-template-areasė grid-areaëĨž ėŽėĐíė ëė ė―ëėīëĪ.
.grid {
display: grid;
grid-template-columns: repeat(4, 100px);
grid-template-rows: repeat(4, 100px);
gap: 10px;
}
.header {
background-color: lightpink;
grid-column-start: 1;
grid-column-end: 5;
grid-row-start: 1;
grid-row-end: 2;
}
.content {
background-color: lightskyblue;
grid-column-start: 1;
grid-column-end: 4;
grid-row-start: 2;
grid-row-end: 4;
}
.nav {
background-color: lightseagreen;
grid-column-start: 4;
grid-column-end: 5;
grid-row-start: 2;
grid-row-end: 4;
}
.footer {
background-color: mediumaquamarine;
grid-column-start: 1;
grid-column-end: 5;
grid-row-start: 4;
grid-row-end: 5;
}
grid-column-start(end)ė grid-row-start(end)ëĨž ėĪėŽ ėļ ė ėëĪ.
startė endëĨž ë°ëĄ ėļ íė ėėī ëĪėęģž ę°ėī ėĪėž ė ėëĪ.
.grid {
display: grid;
grid-template-columns: repeat(4, 100px);
grid-template-rows: repeat(4, 100px);
gap: 10px;
}
.header {
background-color: lightpink;
grid-column: 1 / 5;
grid-row: 1 / 2;
}
.content {
background-color: lightskyblue;
grid-column: 1 / 4;
grid-row: 2 / 4;
}
.nav {
background-color: lightseagreen;
grid-column: 4 / 5;
grid-row: 2 / 4;
}
.footer {
background-color: mediumaquamarine;
grid-column: 1 / 5;
grid-row: 4 / 5;
}
ėëĨž ëĪėī, lineėī ëŠ ę°ėļė§, ėīëė ëëëė§ ė ęē― ėļ íė ėėī -1ė ė ėžëĐī ę·ļ ėĪ lineė ëęđė§ grid itemėī ë§ëĪėīė§ëĪ.
grid-column: 1 / 5;
grid-row: 1 / 2;
ėīë ëĪėęģž ę°ëĪ.
grid-column: 1 / -1;
grid-row: 1 / 2;
ëĪëĨļ ėëĄë, ėĪė contentę° ėžë§ë ęļļ ęēėļė§ ëŊļëĶŽ ė ė ėė ë ėŽėĐíëĐī ė ėĐíëĪ.
.content {
background-color: lightskyblue;
grid-column: 1 / 4;
grid-row: 2 / 4;
}
ėĪė ëĄ contentę° 4ėė ëë ė§ 7ėė ëë ė§ ëŠĻëĨž ë -2ëĨž ėŽėĐíëĐī ëŽīėĄ°ęąī ëėė 2ëēė§ļ lineęđė§ grid itemėī ë§ëĪėīė§ëĪ.
.content {
background-color: lightskyblue;
grid-column: 1 / -2;
grid-row: 2 / -2;
}
ėėęģž ë lineė ė ë ëė ė spanė ėŽėĐí ė ėëĪ.
ėžë§ë ë§ė grid cellė ę°ė§ęģ ėëę°ëĨž ė ë ęēėīëĪ.
.header {
background-color: lightpink;
grid-column: 1 / -1;
grid-row: span 1;
}
.content {
background-color: lightskyblue;
grid-column: 1 / -2;
grid-row: span 2;
}
íėí ęē―ė° ėė lineė ėė íĻęŧ ė ėīėĪ ė ėëĪ.
grid-row: 1 / span 1;
spanėī ėëëž lineė ėŽėĐíęģ ė í ë
íėë ėëęģ ė í ėŽíėīė§ë§ lineė ėīëĶė ė§ėīėĪ ėë ėëĪ.
.grid {
display: grid;
grid-template-columns: [first-line] 100px [second-line] 100px [third-line] 100px [fourth-line] 100px [fifth-line];
grid-template-rows: repeat(4, 100px [line]);
gap: 10px;
}
.header {
background-color: lightpink;
grid-column: first-line / fifth-line;
grid-row: 1 / line 1;
}
.content {
background-color: lightskyblue;
grid-column: first-line / fourth-line;
grid-row: line 1 / line -2;
}
.nav {
background-color: lightseagreen;
grid-column: fourth-line / fifth-line;
grid-row: line 1 / line -2;
}
.footer {
background-color: mediumaquamarine;
grid-column: first-line / fifth-line;
grid-row: line 3 / line 4;
}
ėīë repeat(4, 100px [line])ėė 100px [line]
ėīëžęģ íęļ° ëëŽļė ėĩėĒ
grid containerėė ë§Ļ ė lineė ėīëĶ ė§ėīėĪ [line]ė íīëđëė§ ėëëĪ.
grid containerė ë§Ļ ė lineė ę°ė ļėĪęļ° ėíīėë ėīëĨž ėëŊļíë 1ė ė ėīėž íëĪ.
grid-row: 1 / line 1;