grid-row-gap

grid-row-gap

The grid-row-gap CSS property specifies the gutter between grid rows.

The effect is as though the affected grid lines acquired width: the grid track between two grid lines is the space between the gutters that represent them. For the purpose of track sizing, each gutter is essentially treated as an extra track of the specified length. Negative values are invalid.

Initial value 0
Applies to grid containers
Inherited no
Percentages yes, as the dimension of the element
Media visual
Computed value the percentage as specified or the absolute length
Animation type a length
Canonical order the unique non-ambiguous order defined by the formal grammar

Syntax

/* <length> values */
grid-row-gap: 20px;
grid-row-gap: 1em;
grid-row-gap: 3vmin;
grid-row-gap: 0.5cm;

/* <percentage> value */
grid-row-gap: 10%;

/* Global values */
grid-row-gap: inherit;
grid-row-gap: initial;
grid-row-gap: unset;

Values

<length-percentage>
Is the width of the gutter separating the grid rows. <percentage> values are relative to the dimension of the element.

Formal syntax

<length-percentage>

where
<length-percentage> = <length> | <percentage>

Example

HTML Content

<div id="grid">
  <div></div>
  <div></div>
  <div></div>
</div>

CSS Content

#grid {
  display: grid;
  height: 200px;
  grid-template-columns: 200px;
  grid-template-rows: repeat(3, 1fr);
  grid-row-gap: 20px;
}

#grid > div {
  background-color: lime;
}

Specifications

Specification Status Comment
CSS Grid Layout
The definition of 'grid-row-gap' in that specification.
Candidate Recommendation Initial definition

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support 57.0[1] 20 (12.10240)-ms[3] 52.0 (52.0)[2] 10.0-ms[3] 44[4] No support[5]
Feature Android Webview Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 57.0[1] 57.0[1] 52.0 (52.0)[2] No support[3] 44[4] No support[5]

[1] Implemented behind the experimental Web Platform features flag in chrome://flags since Chrome 29.0. Since Chrome 57.0 it is enabled by default.

[2] Implemented behind the preference layout.css.grid.enabled since Gecko 40.0 (Firefox 40.0 / Thunderbird 40.0 / SeaMonkey 2.37), defaulting to false. Since Gecko 52.0 (Firefox 52.0 / Thunderbird 52.0 / SeaMonkey 2.49) it is enabled by default.

[3] Internet Explorer implements an older version of the specification, which didn't define this property.

[4] Implemented behind the Enable experimental Web Platform features flag in chrome://flags since Opera 28.0.

[5] Experimental implementation available in Safari Technological Preview.

See also

© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-gap

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部