DeveloperBreeze

Grids Cheatsheet

css html

Native CSS Grid

Grid Container Properties

.container {
  display: grid;
  /* OR */
  display: inline-grid;

  /* Define columns */
  grid-template-columns: 100px 100px 100px;        /* Fixed width */
  grid-template-columns: 1fr 1fr 1fr;              /* Fractional units */
  grid-template-columns: repeat(3, 1fr);           /* Repeat syntax */
  grid-template-columns: minmax(100px, 1fr);       /* Responsive columns */
  grid-template-columns: auto 1fr auto;            /* Auto-sized columns */

  /* Define rows */
  grid-template-rows: 100px 100px;                 /* Fixed height */
  grid-template-rows: repeat(3, minmax(100px, auto)); /* Responsive rows */

  /* Define template areas */
  grid-template-areas:
    "header header header"
    "sidebar main main"
    "footer footer footer";                        /* Named grid areas */

  /* Gaps */
  gap: 20px;                                       /* Both row and column gap */
  row-gap: 20px;                                   /* Row gap only */
  column-gap: 20px;                                /* Column gap only */

  /* Grid alignment */
  justify-items: start | end | center | stretch;   /* Horizontal alignment */
  align-items: start | end | center | stretch;     /* Vertical alignment */
  place-items: center center;                      /* Shorthand for both */

  /* Grid content alignment */
  justify-content: start | end | center | space-between | space-around;
  align-content: start | end | center | space-between | space-around;

  /* Auto-flow */
  grid-auto-flow: row | column | dense;
}

Grid Item Properties

.item {
  /* Grid Area - Multiple ways to use it */
  grid-area: header;                              /* Named template area */
  grid-area: 1 / 1 / 2 / 3;                       /* row-start/column-start/row-end/column-end */
  grid-area: 2 / span 3;                          /* Start at row 2, span 3 columns */

  /* Individual grid-row/column properties */
  grid-column: 1 / 3;                             /* Start / end column */
  grid-column: span 2;                            /* Span multiple columns */
  grid-row: 1 / 3;                                /* Start / end row */

  /* Individual alignment */
  justify-self: start | end | center | stretch;
  align-self: start | end | center | stretch;
  place-self: center center;                      /* Shorthand for both */
}

/* Example usage of grid-area with template areas */
.header { grid-area: header; }
.sidebar { grid-area: sidebar; }
.main { grid-area: main; }
.footer { grid-area: footer; }

Tailwind CSS Grid

Grid Container Classes

<!-- Basic grid -->
<div class="grid">

<!-- Column configurations -->
<div class="grid grid-cols-3">                    <!-- 3 equal columns -->
<div class="grid grid-cols-none">                 <!-- No columns -->
<div class="grid grid-cols-[200px_1fr_200px]">    <!-- Custom columns -->

<!-- Row configurations -->
<div class="grid grid-rows-3">                    <!-- 3 equal rows -->
<div class="grid grid-rows-[200px_1fr_100px]">    <!-- Custom rows -->

<!-- Gaps -->
<div class="gap-4">                               <!-- Both row and column gap -->
<div class="gap-x-4">                             <!-- Column gap only -->
<div class="gap-y-4">                             <!-- Row gap only -->

<!-- Auto flow -->
<div class="grid-flow-row">
<div class="grid-flow-col">
<div class="grid-flow-dense">

<!-- Alignment -->
<div class="justify-items-start">
<div class="justify-items-center">
<div class="items-center">                        <!-- Vertical alignment -->

Grid Item Classes

<!-- Column span -->
<div class="col-span-2">                          <!-- Span 2 columns -->
<div class="col-start-2">                         <!-- Start at column 2 -->
<div class="col-end-4">                           <!-- End at column 4 -->

<!-- Row span -->
<div class="row-span-2">                          <!-- Span 2 rows -->
<div class="row-start-2">                         <!-- Start at row 2 -->
<div class="row-end-4">                           <!-- End at row 4 -->

<!-- Individual alignment -->
<div class="justify-self-start">
<div class="justify-self-center">
<div class="self-center">                         <!-- Vertical self-alignment -->

Bootstrap Grid (v5)

Container Classes

<!-- Basic grid container -->
<div class="container">
<div class="container-fluid">                     <!-- Full-width container -->

<!-- Row -->
<div class="row">                                 <!-- Basic row -->
<div class="row g-3">                             <!-- Row with gap -->

<!-- Responsive behavior -->
<div class="row row-cols-1">                      <!-- 1 column -->
<div class="row row-cols-md-2">                   <!-- 2 columns on md screens -->
<div class="row row-cols-lg-3">                   <!-- 3 columns on lg screens -->

Column Classes

<!-- Basic columns -->
<div class="col">                                 <!-- Equal width -->
<div class="col-6">                               <!-- 6/12 width -->
<div class="col-auto">                            <!-- Content-width -->

<!-- Responsive columns -->
<div class="col-sm-6">                           <!-- 6/12 on small screens -->
<div class="col-md-4">                           <!-- 4/12 on medium screens -->
<div class="col-lg-3">                           <!-- 3/12 on large screens -->

<!-- Column ordering -->
<div class="order-1">                            <!-- Order first -->
<div class="order-last">                         <!-- Order last -->

<!-- Offset -->
<div class="offset-md-3">                        <!-- Offset by 3 columns -->

<!-- Alignment -->
<div class="align-self-start">
<div class="align-self-center">
<div class="align-self-end">

Common Breakpoints

/* Bootstrap breakpoints */
--bs-breakpoint-sm: 576px;
--bs-breakpoint-md: 768px;
--bs-breakpoint-lg: 992px;
--bs-breakpoint-xl: 1200px;
--bs-breakpoint-xxl: 1400px;

/* Tailwind default breakpoints */
sm: '640px'
md: '768px'
lg: '1024px'
xl: '1280px'
2xl: '1536px'

Continue Reading

Discover more amazing content handpicked just for you

Cheatsheet

ShadCN Cheatsheet

npm install --save-dev @testing-library/react @testing-library/jest-dom
components/
│
├── ui/           # All ShadCN UI components
│   ├── button.tsx
│   ├── card.tsx
│   └── ...
├── shared/       # Your own custom UI components
├── layout/       # Layout wrappers

Apr 12, 2025
Read More
Cheatsheet
python

Python List Operations Cheatsheet

my_list = ["apple", "banana"]
my_list.insert(1, "cherry")
print(my_list)  # Output: ['apple', 'cherry', 'banana']
my_list = ["apple", "banana"]
my_list.extend(["cherry", "orange"])
print(my_list)  # Output: ['apple', 'banana', 'cherry', 'orange']

Oct 24, 2024
Read More
Cheatsheet

Essential dpkg Commands Cheat Sheet for Debian and Ubuntu Systems

  dpkg --list

Displays all installed packages.

Oct 24, 2024
Read More
Cheatsheet

Best Tools for Generating Backgrounds Patterns for Your Website

You can visit the individual websites to try out their features and start generating stunning, professional patterns for free.

Oct 21, 2024
Read More
Cheatsheet

PM2 Cheatsheet

pm2 save
  • Save the list of running apps for auto-respawn after system restart.

Oct 14, 2024
Read More
Tutorial
javascript css +1

دليل شامل لتطوير الويب: بناء موقع بسيط باستخدام HTML, CSS وJavaScript

  • افتح ملف index.html باستخدام أي متصفح لرؤية الموقع قيد التشغيل.
  • يمكنك إضافة المزيد من التفاعلات باستخدام JavaScript مثل تغيير الألوان عند تمرير الفأرة على الروابط.
  • جرب إضافة مكتبات مثل Bootstrap أو Tailwind CSS لتحسين التصميم.
  • استخدم localStorage لتخزين بيانات النموذج محليًا إذا كنت ترغب في إضافة المزيد من التعقيد إلى المشروع.

Sep 27, 2024
Read More
Tutorial
css

Creating Fluid and Adaptive Typography with CSS

Before jumping into fluid typography, it’s important to understand the basics of relative font sizing using em and rem units. These units allow your text to scale relative to the size of the root element or the parent element.

  • em: Font size is relative to the parent element's font size. It can be affected by the cascading effect of CSS, making it potentially harder to predict.

Sep 05, 2024
Read More
Tutorial
css

CSS Variables and Custom Properties: Dynamic Theming and Beyond

CSS variables are highly effective when building component-based designs, as they allow for flexibility and reusability.

You can define component-specific variables that can be easily overridden for different contexts.

Sep 05, 2024
Read More
Tutorial
css

Advanced Flexbox Techniques: Creating Responsive and Adaptive Designs

When more items are added, they will wrap onto the next line automatically, making your design adaptive.

While Flexbox isn’t designed to replace CSS Grid, it can be used to create simple grid-like layouts.

Sep 05, 2024
Read More
Cheatsheet
rust

Rust Web Frameworks Cheatsheet: A Quick Reference Guide

  • Highly composable and flexible
  • Strong type safety and minimal boilerplate
  • Lightweight and efficient
  • May be too minimalistic for some use cases
  • Learning curve for understanding filters

Aug 29, 2024
Read More
Cheatsheet
rust

Rust Cheatsheet

let s1 = String::from("hello");
let s2 = s1; // s1 is now invalid
  • Clone:

Aug 29, 2024
Read More
Cheatsheet

REST API Cheatsheet: Comprehensive Guide with Examples

No preview available for this content.

Aug 24, 2024
Read More
Cheatsheet
solidity

Blockchain Libraries Cheatsheet

This cheatsheet highlights essential blockchain libraries that are crucial for developing secure, efficient, and feature-rich blockchain applications. Whether you're working on Ethereum, Bitcoin, or other blockchain platforms, these libraries provide the tools needed to interact with blockchains, manage cryptographic operations, and build decentralized applications.

Aug 23, 2024
Read More
Cheatsheet
solidity

Blockchain Development Tools, Libraries, and Frameworks Cheatsheet

  • Description: The official documentation for the Ethereum blockchain, covering topics from basics to advanced development.
  • Key Features:
  • Comprehensive guides on setting up development environments.
  • Tutorials on smart contract development and DApp creation.
  • Detailed explanations of Ethereum concepts and protocols.
  • Regularly updated with the latest information.
  • Website: Ethereum Documentation
  • Description: The official documentation for OpenZeppelin’s smart contract libraries and tools.
  • Key Features:
  • Guides on using OpenZeppelin Contracts, SDK, and Defender.
  • Best practices for secure smart contract development.
  • Tutorials on integrating OpenZeppelin tools with DApps.
  • Regularly updated with the latest security features.
  • Website: OpenZeppelin Documentation

Aug 23, 2024
Read More
Cheatsheet
solidity

Solidity Cheatsheet

  • Use immutable and constant for variables that do not change.

  • Leverage view and pure functions to save gas on reads.

Aug 22, 2024
Read More
Cheatsheet

VPN Services Cheat Sheet: Top Providers and Apps

  • Key Features:
  • 2,000+ servers in 75+ countries.
  • Unlimited device connections.
  • No-log policy.
  • 24/7 customer support.
  • SugarSync encrypted storage.
  • Pricing:
  • $11.99/month (monthly plan).
  • $3.99/month (1-year plan).
  • Supported Platforms:
  • Windows, macOS, iOS, Android, Linux, routers, Smart TVs.
  • Key Features:
  • Free plan with 10GB/month.
  • 110+ server locations in 60+ countries.
  • Built-in ad and tracker blocker.
  • Config generator for custom VPN setups.
  • No-log policy.
  • Pricing:
  • Free plan available.
  • $9.00/month (monthly plan).
  • $5.75/month (1-year plan).
  • Supported Platforms:
  • Windows, macOS, iOS, Android, Linux, browsers, routers.

Aug 21, 2024
Read More
Cheatsheet

CSS-in-JS Libraries Cheatsheet

CSS-in-JS libraries provide a powerful way to manage styles in React applications, offering scoped styles, dynamic theming, and improved maintainability. Whether building a small project or a large-scale application, these tools can help you manage your styles effectively.

📌 Consider your project's complexity, performance needs, and team preference when choosing a CSS-in-JS solution.

Aug 21, 2024
Read More
Cheatsheet

Comprehensive React Libraries Cheatsheet

No preview available for this content.

Aug 21, 2024
Read More
Cheatsheet

Responsive Design Frameworks Cheatsheet

  • Can be heavy without customization.
  • Sites may look similar if not customized.

Foundation is a responsive framework aimed at scalable and flexible web applications.

Aug 21, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!