diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/table-layout | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/css/table-layout')
-rw-r--r-- | files/zh-cn/web/css/table-layout/index.html | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/table-layout/index.html b/files/zh-cn/web/css/table-layout/index.html new file mode 100644 index 0000000000..a6b0b99c0a --- /dev/null +++ b/files/zh-cn/web/css/table-layout/index.html @@ -0,0 +1,117 @@ +--- +title: table-layout +slug: Web/CSS/table-layout +tags: + - CSS + - table-layout + - 单元格 + - 表格 +translation_of: Web/CSS/table-layout +--- +<div>{{CSSRef}}</div> + +<div></div> + +<p><strong>table-layout </strong>CSS属性定义了用于布局表格<em>单元格</em>,<em>行</em>和<em>列</em>的算法。</p> + +<pre><code>/* Keyword values */ +table-layout: auto; +table-layout: fixed; + +/* Global values */ +table-layout: inherit; +table-layout: initial; +table-layout: unset;</code></pre> + +<p>{{cssinfo}}</p> + +<h2 id="Syntax" name="Syntax">语法</h2> + +<pre class="brush: css">/* Keyword values */ +table-layout: auto; +table-layout: fixed; + +/* Global values */ +table-layout: inherit; +table-layout: initial; +table-layout: unset; +</pre> + +<h3 id="Values" name="Values">值</h3> + +<dl> + <dt>{{Cssxref("auto")}}</dt> + <dd>大多数浏览器采用自动表格布局算法对表格布局。表格及单元格的宽度取决于其包含的内容。</dd> + <dt><code>fixed</code></dt> + <dd>表格和列的宽度通过表格的宽度来设置,某一列的宽度仅由该列首行的单元格决定。在当前列中,该单元格所在行之后的行并不会影响整个列宽。<br> + <br> + 使用 “fixed” 布局方式时,整个表格可以在其首行被下载后就被解析和渲染。这样对于 “automatic” 自动布局方式来说可以加速渲染,但是其后的单元格内容并不会自适应当前列宽。任何一个包含溢出内容的单元格可以使用 {{Cssxref("overflow")}} 属性控制是否允许内容溢出。</dd> +</dl> + +<h3 id="正式语法">正式语法</h3> + +<pre class="syntaxbox">{{csssyntax}} +</pre> + +<h2 id="示例">示例</h2> + +<p>本示例使用了fixed的表格布局,结合{{cssxref("width")}}属性来限制表格的宽。{{cssxref("text-overflow")}} 属性用于文字过长时显示省略号。</p> + +<p>如果表格的布局是auto,即使指定了表格的width,表格仍然会自适应内容自动撑开。</p> + +<h3 id="HTML">HTML</h3> + +<pre class="brush: html"><code><table> + <tr><td>Ed</td><td>Wood</td></tr> + <tr><td>Albert</td><td>Schweitzer</td></tr> + <tr><td>Jane</td><td>Fonda</td></tr> + <tr><td>William</td><td>Shakespeare</td></tr> +</table></code> +</pre> + +<h3 id="CSS">CSS</h3> + +<pre class="brush: css"><code>table { + table-layout: fixed; + width: 120px; + border: 1px solid red; +} + +td { + border: 1px solid blue; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +}</code> +</pre> + +<h3 id="结果">结果</h3> + +<p>{{EmbedLiveSample('示例')}}</p> + +<h2 id="Specifications" name="Specifications">规范</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('CSS2.1', 'tables.html#width-layout', 'table-layout')}}</td> + <td>{{Spec2('CSS2.1')}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> + +<article> +<p>{{Compat("css.properties.table-layout")}}</p> +</article> + +<div id="compat-mobile"></div> |