February 06, 2023  SEONews

How To Build A Magazine Layout With CSS Grid Areas — Smashing Magazine


Web development, especially what you can do with CSS, has become increasingly complex. With the added capabilities of CSS Grid, it is now possible to achieve layouts that look like they were laid out by hand. Let’s tackle a practical example of how to do something like that.

In this article, I want to talk about the amazing possibilities of a CSS grid and how it allows for complex layouts that are closer to a print design. The design we’ll discuss is actually one I got to work on for a client (modified slightly to a demo case). It will cover two big use cases of a CSS grid:

  1. Having a static grid where we define the specified start and end points for each element;
  2. Using CSS grid template areas to reorder a simple HTML layout easily without updating the HTML.

As a bonus, we will also touch on object-fit and aspect-ratio, which come in handy as well.

Here you can see the design we will be implementing: desktop on the left and a cropped version for mobile on the right (imagine the mobile view to continue with sections 3 and 4). There is quite a lot going on here, and nothing really fits into neat rows and columns. The images are laid out on an uneven grid, sometimes even overlapping, and we have some narrow text and a numbering element that double as a design element.

More after jump! Continue reading below

Artisanal Image Layouts

Let us first look at the image grid elements inside each colored component. While we have four colored components, there are only two...



source: https://news.oneseocompany.com/2023/02/06/how-to-build-a-magazine-layout-with-css-grid-areas-smashing-magazine_2023020640288.html

Your content is great. However, if any of the content contained herein violates any rights of yours, including those of copyright, please contact us immediately by e-mail at media[@]kissrpr.com.