CSS Layout Patterns #7

If you don’t have time to read but want to know what’s there in this post. Find the quick read 👇Quick ReadOn this SeriesWe are going to look at the commonly used CSS layout patterns. Most of the patterns which we are going to see use CSS grid and flexb…


This content originally appeared on Level Up Coding - Medium and was authored by Nidhin kumar

If you don’t have time to read but want to know what’s there in this post. Find the quick read 👇

Quick Read

On this Series

We are going to look at the commonly used CSS layout patterns. Most of the patterns which we are going to see use CSS grid and flexbox to achieve the common UI patterns such as cards, dynamic grid areas, and full-page layouts supported on all modern browsers.

The patterns which we are going to see in this series are

  1. Aspect ratio Image Card
  2. Clamping Card
  3. Deconstructed Pancake
  4. Holy grail layout
  5. Line up
  6. Pancake Stack
  7. RAM (Repeat, Auto, Minmax)
  8. Sidebar says something
  9. Super centered
  10. 12-span grid
  11. Autobot
  12. Container query card
  13. Content center
  14. Fluffy center
  15. Gentle flex
  16. Pop n’ Plop

On this Post

In this post, we are going to see the following patterns that are

  1. Content center
  2. Fluffy center

1. Content center

A centering technique that is only a few lines of CSS, works great for many elements, but has the side effect of making children match the width of the widest element.

It can be used in grid as well as in flex since it centers and justifies children collectively, it’s a solid centering technique for groups of elements meant to be read.

.content-center {
display: grid;
place-content: center;
gap: 1ch;
}
  • Content is centered even under constrained space and overflow
  • Centering edits and maintenance are all in one spot
  • Gap guarantees equal spacing amongst n children
  • Grid creates rows by default
Content Center Demo

Content centers are great for macro layouts containing paragraphs and headlines, prototypes, or generally things that need legible centering.

2. Fluffy Center

A centering technique that puts the content in the center via equal padding around all its sides.

It is the only centering technique that’s entirely element/child owned.

Fluffy Center Demo
  • Protects content
  • Every test is secretly containing this centering strategy
  • Word space is gap
  • There’s a clash between the container and the items, naturally since each are being very firm about their sizing

Fluffy center are great for word or phrase-centric centering, tags, pills, buttons, chips, and more.

Congratulations!!!

End Note

CSS Layout Patterns #7 was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Level Up Coding - Medium and was authored by Nidhin kumar


Print Share Comment Cite Upload Translate Updates
APA

Nidhin kumar | Sciencx (2022-10-12T17:28:24+00:00) CSS Layout Patterns #7. Retrieved from https://www.scien.cx/2022/10/12/css-layout-patterns-7/

MLA
" » CSS Layout Patterns #7." Nidhin kumar | Sciencx - Wednesday October 12, 2022, https://www.scien.cx/2022/10/12/css-layout-patterns-7/
HARVARD
Nidhin kumar | Sciencx Wednesday October 12, 2022 » CSS Layout Patterns #7., viewed ,<https://www.scien.cx/2022/10/12/css-layout-patterns-7/>
VANCOUVER
Nidhin kumar | Sciencx - » CSS Layout Patterns #7. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/10/12/css-layout-patterns-7/
CHICAGO
" » CSS Layout Patterns #7." Nidhin kumar | Sciencx - Accessed . https://www.scien.cx/2022/10/12/css-layout-patterns-7/
IEEE
" » CSS Layout Patterns #7." Nidhin kumar | Sciencx [Online]. Available: https://www.scien.cx/2022/10/12/css-layout-patterns-7/. [Accessed: ]
rf:citation
» CSS Layout Patterns #7 | Nidhin kumar | Sciencx | https://www.scien.cx/2022/10/12/css-layout-patterns-7/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.