0

I have a basic page layout of header, content, sidebar and footer.
The content should ALWAYS have a max width 1150px,
and the sidebar IF present should additionally have a max width of 450px.
1150 without, 1600px.

I'm using CSS grid width the following code:

.main {
  display: grid;
  gap: 20px;
  align-items: center; // <-- THIS
  grid-template-areas:
    "header   header "
    "content  sidebar"
    "footer   footer ";
  grid-template-columns: fit-content(1150px) fit-content(450px);
}

.main__header { grid-area: header; }
.main__content { grid-area: content; }
.main__sidebar { grid-area: sidebar; }
.main__footer { grid-area: footer; }
<div class="main">
    <div class="main__header"></div>
    <div class="main__content"></div>
    <div class="main__sidebar"></div>
    <div class="main__footer"></div>
</div>

However, using align-items: center doesn't seem to work on the element and center it as expected.

Devon Ville
  • 2,001
  • 2
  • 19
  • 32

0 Answers0