Full Stack Web Development
Step 3 / 21120 min

Responsive Layout (Flexbox & Grid)

Web Foundations

Explanation

Use Flexbox for one-dimensional alignment and CSS Grid for page structure so layouts work from phone to desktop.

Code example

css
.page {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

@media (min-width: 768px) {
  .page {
    grid-template-columns: 240px 1fr;
  }
}

Helpful resources

Exercise

Rebuild your profile as a responsive layout with a flex navbar and a grid main/sidebar.

Responsive Layout (Flexbox & Grid) · Full Stack Web Development | XirfadHub Roadmap