From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/css/row-gap/index.html | 153 +++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 files/zh-cn/web/css/row-gap/index.html (limited to 'files/zh-cn/web/css/row-gap/index.html') diff --git a/files/zh-cn/web/css/row-gap/index.html b/files/zh-cn/web/css/row-gap/index.html new file mode 100644 index 0000000000..2749f187da --- /dev/null +++ b/files/zh-cn/web/css/row-gap/index.html @@ -0,0 +1,153 @@ +--- +title: row-gap (grid-row-gap) +slug: Web/CSS/row-gap +translation_of: Web/CSS/row-gap +--- +
{{CSSRef}}
+ +

 row-gap 该 CSS 属性用来设置行元素之间的间隙({{glossary("gutters","gutter")}}) 大小。

+ +
{{EmbedInteractiveExample("pages/css/grid-row-gap.html")}}
+ + + +
+

CSS Grid Layout 起初是用 grid-row-gap 属性来定义的,目前逐渐被 row-gap 替代。但是,为了兼容那些不支持 row-gap 属性的浏览器,你需要像上面的例子一样使用带有前缀的属性。

+
+ +

语法

+ +
/* <length> values */
+row-gap: 20px;
+row-gap: 1em;
+row-gap: 3vmin;
+row-gap: 0.5cm;
+
+/* <percentage> value */
+row-gap: 10%;
+
+/* Global values */
+row-gap: inherit;
+row-gap: initial;
+row-gap: unset;
+
+ +

+ +
+
<length-percentage>
+
表示行之间的间隔宽度。 {{cssxref("<percentage>")}} 表示相对栅格容器的百分比。
+
+ +

正式语法

+ +
{{csssyntax}}
+ +

示例

+ +

Flex布局

+ +

{{SeeCompatTable}}

+ +

HTML

+ +
<div id="flexbox">
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+</div>
+
+ +

CSS

+ +
#flexbox {
+  display: flex;
+  flex-wrap: wrap;
+  width: 300px;
+  row-gap: 20px;
+}
+
+#flexbox > div {
+  background-color: lime;
+  flex: 1 1 auto;
+  width: 100px;
+  height: 50px;
+
+}
+
+ +

结果

+ +

{{EmbedLiveSample('Flex布局', "auto", "120px")}}

+ +

Grid布局

+ +

HTML

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

CSS

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

结果

+ +

{{EmbedLiveSample('Grid布局', 'auto', 120)}}

+ +

规范

+ + + + + + + + + + + + + + + + +
规范状态备注
{{SpecName("CSS3 Box Alignment", "#propdef-row-gap", "row-gap")}}{{Spec2("CSS3 Box Alignment")}}初始定义
+ +

{{cssinfo}}

+ +

浏览器兼容性

+ + + +

在Flex布局中的兼容性

+ +

{{Compat("css.properties.row-gap.flex_context")}}

+ +

在网格布局中的兼容性

+ +

{{Compat("css.properties.row-gap.grid_context")}}

+ +

参见

+ + -- cgit v1.2.3-54-g00ecf