• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

Css Basic: grid-template-rows

December 20, 2023

CSS Basics: grid-template-rows

In the world of web development, CSS (Cascading Style Sheets) plays a crucial role in designing and styling websites. One of the most powerful features of CSS is the grid layout, which allows developers to create complex and responsive web designs. In this article, we will explore the grid-template-rows property and its usage in CSS.

Understanding the grid-template-rows Property

The grid-template-rows property is a part of the CSS Grid Layout module. It defines the size and position of the rows in a grid container. By using this property, developers can specify the height of each row individually or use different units of measurement to create flexible and dynamic layouts.

Here is the basic syntax of the grid-template-rows property:

grid-template-rows: <track-size> ... | <line-name> <track-size> ... | subgrid

The <track-size> represents the height of each row, and it can be defined using various units such as pixels, percentages, or the fr unit, which represents a fraction of the available space. Multiple <track-size> values can be specified to define the height of each row individually.

Alternatively, developers can use <line-name> to reference named grid lines and assign a specific height to them. This allows for more flexibility and control over the grid layout.

Examples

Let’s take a look at some examples to understand how the grid-template-rows property works:

.grid-container {
  display: grid;
  grid-template-rows: 100px 200px 1fr;
}

In this example, the grid container will have three rows. The first row will have a fixed height of 100 pixels, the second row will have a fixed height of 200 pixels, and the third row will occupy the remaining space using the fr unit.

.grid-container {
  display: grid;
  grid-template-rows: repeat(3, 1fr);
}

In this case, the repeat() function is used to create three rows with equal heights. Each row will occupy an equal fraction of the available space.

Conclusion

The grid-template-rows property is a powerful tool in CSS that allows developers to create flexible and dynamic grid layouts. By defining the height of each row individually or using different units of measurement, developers can achieve complex and responsive designs. Understanding and utilizing this property can greatly enhance the visual appeal and functionality of websites.

Summary

In conclusion, the grid-template-rows property in CSS is used to define the size and position of rows in a grid container. It offers flexibility and control over the layout by allowing developers to specify the height of each row individually or using different units of measurement. To learn more about CSS and web development, consider exploring Server.HK, a leading VPS hosting company that provides reliable and high-performance hosting solutions.

Recent Posts

  • How to Deploy a Node.js Application on Hong Kong VPS: Complete Guide
  • How to Set Up a WordPress Site on a Hong Kong VPS with aaPanel (Step-by-Step 2026)
  • How to Choose the Right Hong Kong VPS Plan: A Buyer’s Guide for 2026
  • CN2 GIA vs BGP vs CN2 GT: What’s the Real Difference for China Connectivity?
  • Top 5 Use Cases for a Hong Kong Dedicated Server in 2026

Recent Comments

No comments to show.

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot