- Services
- Case Studies
- Technologies
- NextJs development
- Flutter development
- NodeJs development
- ReactJs development
- About
- Contact
- Tools
- Blogs
- FAQ
CSS Row-Gap Manage Space Between Rows
It accepts lengths, percentages, and global keywords for flexibility.
Understanding row-gap in CSS
The row-gap property in CSS helps you control the space between rows in flex and grid containers. It’s great for keeping your layouts clean and organized. Let’s dive into some examples.
Example: Using row-gap in Flexbox
HTML
<div class="flex-row-gap"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> <div>6</div> <div>7</div> <div>8</div> <div>9</div> <div>10</div> <div>11</div> <div>12</div> <div>13</div></div>CSS
.flex-row-gap { background-color: #776fac; padding: 5px; display: flex; flex-wrap: wrap; row-gap: 25px;}
.flex-row-gap > div { background-color: aliceblue; margin: 5px; height: 80px; line-height: 80px; text-align: center; font-size: 18px; width: 100px;}Result
In this example, row-gap: 25px creates a 25-pixel gap between each row of items. This helps maintain consistent spacing and makes the layout look neat.
Example: Using row-gap in Grid Layout
HTML
<div class="grid-row-gap"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> <div>6</div> <div>7</div> <div>8</div> <div>9</div></div>CSS
.grid-row-gap { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); row-gap: 25px; height: 300px;}
.grid-row-gap > div { background-color: aliceblue; border: 1px solid green; display: flex; align-items: center; justify-content: center; font-size: 18px;}Result
In this grid example, row-gap: 25px creates a 25-pixel gap between each row. This keeps the grid items evenly spaced and visually appealing.
Interactive Example: Changing row-gap Values
HTML
<div class="flex-row-gap"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> <div>6</div> <div>7</div> <div>8</div> <div>9</div> <div>10</div> <div>11</div> <div>12</div> <div>13</div></div>
<button onclick="changeRowGap('50px')">Set row-gap to 50px</button><button onclick="changeRowGap('normal')">Set row-gap to normal</button><button onclick="changeRowGap('initial')">Set row-gap to initial</button><button onclick="changeRowGap('inherit')">Set row-gap to inherit</button>CSS
.flex-row-gap { background-color: #776fac; padding: 5px; display: flex; flex-wrap: wrap; row-gap: normal;}
.flex-row-gap > div { background-color: aliceblue; margin: 5px; height: 80px; line-height: 80px; text-align: center; font-size: 18px; width: 100px;}JavaScript
function changeRowGap(value) { document.querySelector('.flex-row-gap').style.rowGap = value;}Result
In this interactive example, you can change the row-gap value by clicking the buttons. This helps you see how different row-gap values affect the layout.
Browser Compatibility
The row-gap property is widely supported across modern browsers, making it a reliable choice for web developers. Here’s a quick overview:
| Browser | Initial Support |
|---|---|
| Chrome | 50.0 (Apr 2016) |
| Firefox | 52.0 (Mar 2017) |
| IE/Edge | 10.0 (Sep 2012) |
| Opera | 37.0 (May 2016) |
| Safari | 9.0 (Sep 2015) |
See Also
If you found the row-gap property useful, you might also be interested in exploring other related CSS properties and concepts:
column-gapProperty: Learn how to manage the space between columns.gapProperty: Discover how to set both row and column gaps in one declaration.- CSS Flexbox Tutorial: Dive into flexbox layouts.
- CSS Grid Layout Tutorial: Explore grid layouts.
- HTML Tutorial: Brush up on your HTML skills.
These resources will help you create more sophisticated and visually appealing web designs.
สร้างเว็บไซต์ 1 เว็บ ต้องใช้งบเท่าไหร่? เจาะลึกทุกองค์ประกอบ website development cost อยากสร้างเว็บไซต์แต่ไม่มั่นใจในเรื่องของงบประมาณ อ่านสรุปเจาะลึกตั้งแต่ดีไซน์, ฟังก์ชัน และการดูแล พร้อมตัวอย่างงบจริงจาก Till it’s done ที่แผนชัด งบไม่บานปลายแน่นอน
Next.js สอน 14 ขั้นตอนเบื้องต้น: สร้างโปรเจกต์แรกใน 30 นาที เริ่มต้นกับ Next.js ใน 14 ขั้นตอนเพียงแค่ 30 นาที พร้อม SSR/SSG และ API Routes ด้วยตัวอย่างโค้ดง่าย ๆ อ่านต่อเพื่อสร้างโปรเจ็กต์แรกได้ทันทีที่นี่
วิธีสมัคร Apple Developer Account เพื่อนำแอปขึ้น App Store ทีละขั้นตอน อยากปล่อยแอปบน App Store ระดับโลก มาอ่านคู่มือสมัคร Apple Developer Account พร้อมเคล็ดลับ TestFlight และวิธีอัปโหลดที่ง่ายในบทความเดียวนี้ได้เลย
TypeScript Interface คืออะไร? อธิบายพร้อมวิธีใช้และข้อแตกต่างจาก Type เรียนรู้วิธีใช้ TypeScript Interface เพื่อสร้างโครงสร้างข้อมูลที่ปลอดภัยและเข้าใจง่าย พร้อมเปรียบเทียบข้อดีข้อแตกต่างกับ Type ที่คุณต้องรู้ ถูกรวมเอาไว้ในบทความนี้แล้ว
Material-UI (MUI) คืออะไร อยากสร้าง UI สวยงามและเป็นมืออาชีพในเวลาอันรวดเร็วใช่ไหม มาทำความรู้จักกับ Material-UI (MUI) ที่ช่วยให้คุณพัฒนาแอปพลิเคชันบน React ได้ง่ายและดูดีในทุกอุปกรณ์
เปรียบเทียบ 3 วิธีติดตั้ง install node js บน Ubuntu: NVM vs NodeSource vs Official Repo แบบไหนดีที่สุด? เรียนรู้วิธีติดตั้ง Node.js บน Ubuntu ด้วย NVM, NodeSource หรือ Official Repo เลือกวิธีที่เหมาะกับความต้องการของคุณ พร้อมเปรียบเทียบ เพื่อการพัฒนาที่มีประสิทธิภาพ! พูดคุยกับซีอีโอ
We'll be right here with you every step of the way.
We'll be here, prepared to commence this promising collaboration.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.