CSS Properties
CSS grid-row-end Property
Photo Credit to CodeToFun
🙋 Introduction
The grid-row-end
property in CSS is used in the Grid Layout to define the ending position of a grid item within the grid's rows.
This property allows you to span grid items over multiple rows, helping you create more complex and flexible layouts.
💡 Syntax
The syntax for the grid-row-end
property is straightforward. You can specify the row line where the grid item should end or the number of rows it should span.
element {
grid-row-end: value;
}
🎛️ Default Value
The default value of the grid-row-end
property is auto, which means the grid item will end at the next available grid line by default.
🏠 Property Values
Value | Description |
---|---|
auto | The grid item will span one row by default. |
line number | The grid item's ending position is defined by the grid line number, e.g., grid-row-end: 3;. |
span value | The grid item will span the specified number of rows, e.g., grid-row-end: span 2;. |
📄 Example
In this example, we'll create a grid layout and set a grid item to span multiple rows.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS grid-row-end Example</title>
<style>
.grid-container {
display: grid;
grid-template-columns: 100px 100px 100px;
grid-template-rows: 100px 100px 100px;
gap: 10px;
}
.item1 {
background-color: lightcoral;
grid-row-end: span 2; /* Spans 2 rows */
}
.item2 {
background-color: lightblue;
}
.item3 {
background-color: lightgreen;
}
</style>
</head>
<body>
<h1>Grid Layout with grid-row-end</h1>
<div class="grid-container">
<div class="item1">Item 1</div>
<div class="item2">Item 2</div>
<div class="item3">Item 3</div>
</div>
</body>
</html>
🖥️ Browser Compatibility
The grid-row-end
property is widely supported in modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. It is advisable to test your grid layouts across different browsers to ensure consistent behavior.
🎉 Conclusion
The grid-row-end
property is a powerful feature of CSS Grid Layout that allows you to control the ending position of grid items within rows.
By using this property, you can create more flexible and dynamic layouts. Experiment with different values to see how you can leverage the grid-row-end
property to enhance your web designs.
👨💻 Join our Community:
Author
For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.
Buy me a coffee to make codetofun.com free for everyone.
Buy me a Coffee
If you have any doubts regarding this article (CSS grid-row-end Property), please comment here. I will help you immediately.