Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Topics

CSS grid-row-end Property

Posted in CSS Tutorial
Updated on Oct 03, 2024
By Mari Selvan
👁️ 19 - Views
⏳ 4 mins
💬 1 Comment
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.

Syntax
Copied
Copy To Clipboard
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

ValueDescription
autoThe grid item will span one row by default.
line numberThe grid item's ending position is defined by the grid line number, e.g., grid-row-end: 3;.
span valueThe 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.

index.html
Copied
Copy To Clipboard
<!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:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

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

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy