| Desktop | Tablet | Mobile |
|---|---|---|
![]() |
![]() |
![]() |
- CSS Grid
- Responsive layout
Lots of valuable lessons! Here are the key ones:
-
100vwincludes the scrollbar in most browsers
This can lead to layout shifts and headaches when aiming for pixel-perfect designs.
Solution: Prefer using100%or other layout strategies that don’t include the scrollbar width. -
Negative margins can pull elements in any direction
Handy for overlapping or fine-tuning layout positioning. -
The CSS
transformproperty
Still working on mastering it. -
Positioning absolutely inside a relatively positioned container
The theory made more sense once I used it in action. -
Centering an absolutely positioned element
Shift the element 50% from the left of the container, then pull it back 50% of its own width:.container { position: relative; } .child { position: absolute; left: 50%; /* this is 50% of the container width*/ transform: translateX(-50%); /* this is 50% of the element width*/ }
🟰 Ta-da! Centered horizontally!
you can apply the same logic to the Y-axis for vertical centering. -
z-indexonly works on positioned elements
That meansrelative,absolute,fixed, orsticky. It’s ignored if the element isstatic. -
Combining background image and color requires a
linear-gradient()
The color layer has to be a gradient—even if it’s just one color. otherwise it won't work☹️ .element { background: linear-gradient( rgba(77, 150, 169, 0.8955), rgba(77, 150, 169, 0.8955) ), url("path/to/image.jpeg") center/cover no-repeat; }
-
Flexbox vs. Grid
If you need a managable two-dimensional layout, don't make my mistake of trying to build it with Flexbox
go with Grid from the beginning.
- Github - @AminForouzan
- Frontend Mentor - @AminForouzan


