I’m trying to use named lines with grid to do the layout but it doesn’t work for me as it should I know where I went wrong because the red section doesn’t want to go next to the footer
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.container {
height: 100vh;
display: grid;
grid-template-columns: [header-start content-start footer-start] 4fr [content-end footer-end section-start] 1fr [header-end section-end];
grid-template-rows: [header-start] 1fr [hrader-end content-start] 3fr [content-end footer-start] 1fr [footer-end];
gap: 10px;
padding: 10px;
}
header {
grid-column: header-start / header-end;
background-color: blanchedalmond;
}
.content {
grid-column: content-start / content-end;
background-color: skyblue;
}
section {
grid-column: section-start / section-end;
background-color: coral;
}
footer {
grid-column: footer-start / footer-end;
background-color: lightseagreen;
}
/*centering*/
.content,
header,
section,
footer {
display: flex;
justify-content: center;
align-items: center;
}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="grid2.css">
<title>grid-line</title>
</head>
<body>
<div class="container">
<header class="header">
HEADER
</header>
<div class="content">
CONTENT
</div>
<section class="text">
TEXT
</section>
<footer class="footer">
FOOTER
</footer>
</div>
</body>
</html>
2
Answers
Change the value of your footer
grid-column: footer-start / footer-end;
This is the layout:
This is what I thought you were expecting, so just in case, in this one the section spawns next to the content:
This is a simplified way of using the display grid property.