Responsive Layout with Sidebar

Beginner

This tutorial is from open-source community. Access the source code

Introduction

In this lab, we will be exploring the world of CSS programming. The main objective of this lab is to provide hands-on experience with creating a responsive layout with a sidebar. By the end of this lab, you will have a better understanding of how to use display: grid and minmax() properties to create an effective and visually appealing layout.

This is a Guided Lab, which provides step-by-step instructions to help you learn and practice. Follow the instructions carefully to complete each step and gain hands-on experience. Historical data shows that this is a beginner level lab with a 100% completion rate. It has received a 100% positive review rate from learners.

index.html and style.css have already been provided in the VM.

To create a responsive layout with a content area and a sidebar, use display: grid on the parent container, minmax() for the second column (sidebar) to allow it to take up between 150px and 20%, and 1fr for the first column (main content) to take up the rest of the remaining space. Here is an example HTML and CSS code:

<div class="container">
  <main>This element is 1fr large.</main>
  <aside>Min: 150px / Max: 20%</aside>
</div>
.container {
  display: grid;
  grid-template-columns: 1fr minmax(150px, 20%);
  height: 100px;
}

main,
aside {
  padding: 12px;
  text-align: center;
}

main {
  background: #d4f2c4;
}

aside {
  background: #81cfd9;
}

Please click on 'Go Live' in the bottom right corner to run the web service on port 8080. Then, you can refresh the Web 8080 Tab to preview the web page.

Summary

Congratulations! You have completed the Responsive Layout With Sidebar lab. You can practice more labs in LabEx to improve your skills.