DEV Community

Cover image for Day 1 of #100DaysOfCode: Design a layout for shopping cart template with CSS grid and Media query
Jen-Hsuan Hsieh
Jen-Hsuan Hsieh

Posted on • Edited on

1

Day 1 of #100DaysOfCode: Design a layout for shopping cart template with CSS grid and Media query

Introduction

What I did on the first day is to create a template for a shopping cart.
Design a layout is a good practice for using some CSS frameworks like CSS grid and Media query for the front-end developer.

Implementations

CSS grid containers

The layout for desktop consists of two CSS grid box.

  • The sidebar and products are the containers of the box 1, the blue one.
.grid-box {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 100px;
    border-radius: 5px;
 }
Enter fullscreen mode Exit fullscreen mode
  • The form is the containers of box 2, the green one.
.grid-box2 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 400px;
    border-radius: 5px;
 }
Enter fullscreen mode Exit fullscreen mode

CSS grid items for desktop

  • Layout
    Alt Text

  • Code

 .products {
    grid-column-start: 2;
    grid-column-end: 4;
 }

 .sidebar1 {
    grid-column-start: 1;
    grid-column-end: 2;
    grid-row-start: 1;
    grid-row-end: 3;
 }

 .step2 {
    grid-column-start: 2;
    grid-column-end: 4;
}
Enter fullscreen mode Exit fullscreen mode

CSS grid items for moble

  • Layout
    Alt Text

  • Code

 .sidebar1 {
        grid-column-start: 1;
        grid-column-end: 4;
        grid-row-start: 1;
        grid-row-end: 3;
     }    

     .products {
        grid-column-start: 1;
        grid-column-end: 4;
     }
Enter fullscreen mode Exit fullscreen mode

Articles

There are some of my articles. Feel free to check if you like!

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay