Since we are talking about macro layouts, I want to take a moment to talk about the max-width property that is commonly attached to any macro layout.
max-width is attached for a very simple reason: because you do not want your grid to expand to the edges of the container. You want it to be reasonably sized — and often, centered.
<div class="grid-simple max-w-[60rem] mx-auto">...</div>A set of 4 widths
When it comes to web design, the alignment of the grid is very important because it gives a sense of order to the page. So it helps to create common values that you can use easily instead of writing your custom values each time.
In practice, I often create four of such widths for easy alignment purposes:
standard: Used for most gridsnarrow: Used for textmid: Used when I need something betweenstandardandnarrowwide: For grids that should expand beyondstandard
@theme { --spacing-narrow: 40rem; /* 640px */ --spacing-mid: 55rem; /* 880px */ --spacing-standard: 65rem; /* 1040px */ --spacing-wide: 80rem; /* 1280px */}Once you have defined them, you can use the keyword to use that width.
<div class="vertical max-w-standard mx-auto"> <!-- Content here --></div>Here are some examples of the various widths in action:
Custom-sized widths are still valid
Do not let purists box you into the belief that you need to use one of these four widths.
The truth is it doesn’t really matter in web design.
Sometimes you want something slightly narrower between mid and standard. That is fine. Sometimes you want something between standard and wide just to create some sort of disturbance and draw attention. That is fine too.
The key really is to break your alignment intentionally and consciously to create the results you want.
Welcome! Unfortunately, you don’t have access to this lesson. To get access, please purchase the course or enroll in Magical Dev School.
Unlock this lesson