How to Make CSS Grid Rows Span Multiple Columns?
Make Rows Span Multiple Columns
Rows in CSS Grid can be configured to encompass multiple columns using the appropriate grid properties. Here's how to achieve this:
Line-based Placement:
The most common approach is through line-based placement, where you specify column start and end lines:
<code class="css">grid-column: 1 / 4; // Spans columns 1, 2, and 3</code>
Explicit Grid Area:
Use the grid-area property, which explicitly defines the occupied cells:
<code class="css">grid-area: 1 / 2 / span 3; // Spans 3 columns from row 1, column 2</code>
Negative Values:
Negative values in grid-column or grid-column-start can be used for right-to-left placement:
<code class="css">grid-column: -2 / -1; // Spans the last 2 columns</code>
Column Line Clamping:
This technique uses line clamping to extend the row's end point to the available space:
<code class="css">grid-column: auto; grid-column-end: 100%;</code>
Auto-sizing with Minimum:
Auto-sizing with a minimum width ensures the row occupies at least a specified number of columns:
<code class="css">grid-column: auto; min-width: 400px;</code>
Example:
To stretch the navigation row across all columns:
<code class="html"><div class="container"> <div class="main-nav"> ... </div> ... </div></code>
<code class="css">.container { display: grid; grid-template-columns: 1fr 2fr 1fr; } .main-nav { grid-column: 1 / -1; // Spans all columns }</code>
By applying one of these methods, you can extend rows or columns across multiple columns in CSS Grid, creating complex and flexible layouts.
The above is the detailed content of How to Make CSS Grid Rows Span Multiple Columns?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

It's out! Congrats to the Vue team for getting it done, I know it was a massive effort and a long time coming. All new docs, as well.

I had someone write in with this very legit question. Lea just blogged about how you can get valid CSS properties themselves from the browser. That's like this.

I'd say "website" fits better than "mobile app" but I like this framing from Max Lynch:

The other day, I spotted this particularly lovely bit from Corey Ginnivan’s website where a collection of cards stack on top of one another as you scroll.

If we need to show documentation to the user directly in the WordPress editor, what is the best way to do it?

There are a number of these desktop apps where the goal is showing your site at different dimensions all at the same time. So you can, for example, be writing

Questions about purple slash areas in Flex layouts When using Flex layouts, you may encounter some confusing phenomena, such as in the developer tools (d...

When the number of elements is not fixed, how to select the first child element of the specified class name through CSS. When processing HTML structure, you often encounter different elements...
