0

body {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background-color: white;
}

div.container {
  display: grid;
  grid-template-columns: 3fr 1fr;
  grid-template-rows: 20vh 70vh 10vh;
  grid-template-areas: "h h" "m a" "f f";
}

header {
  background: yellow;
  grid-area: h;
}

main {
  background: blue;
  grid-area: m;
}

aside {
  background: green;
  grid-area: a;
}

footer {
  background: red;
  grid: f;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Site</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <div class="container">
    <header></header>
    <main></main>
    <aside></aside>
    <footer></footer>
  </div>
</body>

</html>

Estou aprendendo CSS-Grid e não consigo descobrir o porquê o footer não ocupa as 4 colunas criadas, apenas as 3 primeiras. Alguém pode me ajudar, prf?

1 Resposta 1

3

footer está com o atributo grid ao invés de grid-area, este é o problema!

body {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background-color: white;
}

div.container {
  display: grid;
  grid-template-columns: 3fr 1fr;
  grid-template-rows: 20vh 70vh 10vh;
  grid-template-areas: "h h" "m a" "f f";
}

header {
  background: yellow;
  grid-area: h;
}

main {
  background: blue;
  grid-area: m;
}

aside {
  background: green;
  grid-area: a;
}

footer {
  background: red;
  grid-area: f;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Site</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <div class="container">
    <header></header>
    <main></main>
    <aside></aside>
    <footer></footer>
  </div>
</body>

</html>

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .