aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/grid-column
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/grid-column
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/css/grid-column')
-rw-r--r--files/zh-cn/web/css/grid-column/index.html195
1 files changed, 195 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/grid-column/index.html b/files/zh-cn/web/css/grid-column/index.html
new file mode 100644
index 0000000000..f6074374b2
--- /dev/null
+++ b/files/zh-cn/web/css/grid-column/index.html
@@ -0,0 +1,195 @@
+---
+title: grid-column
+slug: Web/CSS/grid-column
+translation_of: Web/CSS/grid-column
+---
+<p><code>grid-column</code> CSS属性是 {{cssxref("grid-column-start")}} 和 {{cssxref("grid-column-end")}} 的简写属性,用于指定网格项目的大小和位置{ 通过为它的网格位置贡献线条,跨度或不添加任何内容(自动),从而指定其 {{glossary("grid area","grid area","网格区域")}}。</p>
+
+<div>{{EmbedInteractiveExample("pages/css/grid-column.html")}}</div>
+
+
+
+<h2 id="语法">语法</h2>
+
+<p>如果给出两个<code>&lt;grid-line&gt;</code>值,它们之间用“ /”分隔。 将<code>grid-column-start</code>的正手设置为斜线之前的值,并将<code>grid-column-end</code>的正手设置为斜线之后的值。</p>
+
+<p>每个<code>&lt;grid-line&gt;</code>值可以指定为:</p>
+
+<ul>
+ <li>要么是<code>auto</code>关键字</li>
+ <li>或<code>&lt;custom-ident&gt;</code>值</li>
+ <li>或<code>&lt;integer&gt;</code>值</li>
+ <li>或者<code>&lt;custom-ident&gt;</code>和<code>&lt;integer&gt;</code>,两者之间用空格分隔</li>
+ <li>或关键字span与<code>&lt;custom-ident&gt;</code>或<code>&lt;integer&gt;</code>或两者一起使用。</li>
+</ul>
+
+<h3 id="值">值</h3>
+
+<p><br>
+ <code>auto</code></p>
+
+<p><br>
+ 是一个关键字,指示该属性对网格项目的放置没有任何作用,表示自动放置,自动跨度或默认跨度为1。</p>
+
+<p><br>
+ <code>&lt;custom-ident&gt;</code></p>
+
+<p><br>
+ 如果有一个名为"&lt;custom-ident&gt;-start"/"&lt;custom-ident&gt;-start"的命名行,则它将第一行添加到网格项目的位置。</p>
+
+<div class="blockIndicator warning">
+<p>注意:命名网格区域会自动生成这种形式的隐式命名行,因此请指定<code>grid-column: foo;</code>将选择该命名网格区域的开始/结束边缘(除非在其之前明确指定了另一条名为<code>foo-start / foo-end</code>的行)。</p>
+</div>
+
+<p>否则,将其视为与<code>&lt;custom-ident&gt;</code>一起指定了整数1。</p>
+
+<p><br>
+ <code>&lt;integer&gt; &amp;&amp; &lt;custom-ident&gt;?</code></p>
+
+<p><br>
+ 将第n条网格线贡献到网格项目的位置。如果给定一个负整数,则从显式网格的末端开始,反向计数。</p>
+
+<p>如果将名称指定为&lt;custom-ident&gt;,则仅计算具有该名称的行。如果没有足够多的具有该名称的线,则假定所有隐式网格线都具有该名称,以查找该位置。</p>
+
+<p>{{cssxref("integer")}}的值为<code>0</code>无效。</p>
+
+<p><code>span &amp;&amp; [ &lt;integer&gt; || &lt;custom-ident&gt; ]</code><br>
+ 将网格范围扩展到该网格项目的位置,以使该网格项目的网格区域的相应边缘距离相对边缘n行。<br>
+ 如果将名称指定为&lt;custom-ident&gt;,则仅计算具有该名称的行。如果没有足够多的具有该名称的线,则为计算此跨度,假定与搜索方向相对应的显式网格侧的所有隐式网格线均具有该名称。</p>
+
+<p>如果省略&lt;integer&gt;,则默认为<code>1</code>。负整数或0无效。</p>
+
+<h3 id="Formal_syntax">Formal syntax</h3>
+
+<pre class="syntaxbox notranslate">{{csssyntax}}</pre>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="HTML_Content">HTML Content</h3>
+
+<pre class="brush: html notranslate">&lt;div id="grid"&gt;
+ &lt;div id="item1"&gt;&lt;/div&gt;
+ &lt;div id="item2"&gt;&lt;/div&gt;
+ &lt;div id="item3"&gt;&lt;/div&gt;
+&lt;/div&gt;</pre>
+
+<h3 id="CSS_Content">CSS Content</h3>
+
+<pre class="brush: css; highlight[14,19] notranslate">#grid {
+ display: grid;
+ height: 100px;
+ grid-template-columns: repeat(6, 1fr);
+ grid-template-rows: 100px;
+}
+
+#item1 {
+ background-color: lime;
+}
+
+#item2 {
+ background-color: yellow;
+ grid-column: 2 / 4;
+}
+
+#item3 {
+ background-color: blue;
+ grid-column: span 2 / 7;
+}
+</pre>
+
+<p>{{EmbedLiveSample("Example", "100%", "100px")}}</p>
+
+<h2 id="IE问题">IE问题</h2>
+
+<p>IE11不支持自动放置网格项目。 除非用-ms-{{cssxref("grid-column")}}和-ms-{{cssxref("grid-row")}}显式注释,否则所有项目都以网格的第一行/列结尾。 可以使用一些JavaScript来启用自动注释:源存储库。</p>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName("CSS3 Grid", "#propdef-grid-column", "grid-column")}}</td>
+ <td>{{Spec2("CSS3 Grid")}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>{{cssinfo}}</p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("css.properties.grid-column")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>Related CSS properties: {{cssxref("grid-row")}}, {{cssxref("grid-row-start")}}, {{cssxref("grid-row-end")}}, {{cssxref("grid-column-start")}}, {{cssxref("grid-column-end")}}</li>
+ <li>Grid Layout Guide: <em><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Line-based_Placement_with_CSS_Grid">Line-based placement with CSS Grid</a></em></li>
+ <li>Video tutorial: <em><a href="http://gridbyexample.com/video/series-line-based-placement/">Line-based placement</a></em></li>
+</ul>
+
+<section class="Quick_links" id="Quick_Links">
+<ol>
+ <li><a href="/en-US/docs/Web/CSS"><strong>CSS</strong></a></li>
+ <li><a href="/en-US/docs/Web/CSS/Reference"><strong>CSS Reference</strong></a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout">CSS Grid Layout</a></li>
+ <li data-default-state="open"><a href="#"><strong>Guides</strong></a>
+ <ol>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout">Basics concepts of grid layout</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Relationship_of_Grid_Layout">Relationship to other layout methods</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Line-based_Placement_with_CSS_Grid">Line-based placement</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Grid_Template_Areas">Grid template areas</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Layout_using_Named_Grid_Lines">Layout using named grid lines</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Auto-placement_in_CSS_Grid_Layout">Auto-placement in grid layout</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Box_Alignment_in_CSS_Grid_Layout">Box alignment in grid layout</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid,_Logical_Values_and_Writing_Modes">Grids, logical values and writing modes</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid_Layout_and_Accessibility">CSS Grid Layout and Accessibility</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid_and_Progressive_Enhancement">CSS Grid Layout and Progressive Enhancement</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Realizing_common_layouts_using_CSS_Grid_Layout">Realizing common layouts using grids</a></li>
+ </ol>
+ </li>
+ <li data-default-state="open"><a href="#"><strong>Properties</strong></a>
+ <ol>
+ <li><a href="/en-US/docs/Web/CSS/grid">grid</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-area">grid-area</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-auto-columns">grid-auto-columns</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-auto-flow">grid-auto-flow</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-auto-rows">grid-auto-rows</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column">grid-column</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column-end">grid-column-end</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column-gap">grid-column-gap</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column-start">grid-column-start</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-gap">grid-gap</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row">grid-row</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row-end">grid-row-end</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row-gap">grid-row-gap</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row-start">grid-row-start</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template">grid-template</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template-areas">grid-template-areas</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template-columns">grid-template-columns</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template-rows">grid-template-rows</a></li>
+ </ol>
+ </li>
+ <li data-default-state="open"><a href="#"><strong>Glossary</strong></a>
+ <ol>
+ <li><a href="/en-US/docs/Glossary/Grid_lines">Grid lines</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_tracks">Grid tracks</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_cell">Grid cell</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_areas">Grid areas</a></li>
+ <li><a href="/en-US/docs/Glossary/Gutters">Gutters</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_rows">Grid row</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_column">Grid column</a></li>
+ </ol>
+ </li>
+</ol>
+</section>