aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/block-size/index.html
blob: c0b755d598c315336433f7bfbd6802bb879e1221 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
title: 块级尺寸
slug: Web/CSS/block-size
translation_of: Web/CSS/block-size
---
<div>{{CSSRef}}{{SeeCompatTable}}</div>

<div>CSS的block-size属性定义了元素区块的水平宽度和垂直高度,也就是{{cssxref("width")}}{{cssxref("height")}}属性,它们的大小取决于写入模式,即{{cssxref("writing-mode")}}的值。</div>

<div>{{EmbedInteractiveExample("pages/css/block-size.html")}} </div>

<div> </div>

<p class="hidden">这个交互例子的源码存在Githubd的仓库中。如果你想为这个交互例子的项目做一份贡献,请从 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a>克隆此项目并给我们发送一个pull请求。</p>

<h2 id="语句">语句</h2>

<pre class="brush:css no-line-numbers">/* &lt;length&gt; values */
block-size: 300px;
block-size: 25em;

/* &lt;percentage&gt; values */
block-size: 75%;

/* Keyword values */
block-size: 25em border-box;
block-size: 75% content-box;
block-size: max-content;
block-size: min-content;
block-size: available;
block-size: fit-content;
block-size: auto;

/* Global values */
block-size: inherit;
block-size: initial;
block-size: unset;If the writing mode is vertically oriented, the value of <code style="font-size: 1rem; letter-spacing: -0.00278rem;">block-size</code><span style="background-color: #ffffff; font-family: Arial,x-locale-body,sans-serif; font-size: 1rem; letter-spacing: -0.00278rem;"> relates to the width of the element; otherwise, it relates to the height of the element. A related property is {{cssxref("inline-size")}}, which defines the other dimension of the element.</span>
</pre>

<p><span style="background-color: #ffffff; font-family: Arial,x-locale-body,sans-serif; font-size: 1rem; letter-spacing: -0.00278rem;">如果写入模式为垂直方向,block-size的值与元素的宽度有关,否则取决于元素的高度。相关的属性是定义了元素的其它大小的</span>{{cssxref("inline-size")}}</p>

<h2 id="语句_2">语句</h2>

<h3 id="值"></h3>

<p> <code>block-size</code> <code>属性的值是</code>p{{cssxref("width")}} 属性与 {{cssxref("height")}} 属性的值的结合。</p>

<h3 id="正式语句">正式语句</h3>

{{csssyntax}}

<h2 id="例子">例子</h2>

<h3 id="HTML">HTML</h3>

<pre class="brush: html">&lt;p class="exampleText"&gt;Example text&lt;/p&gt;
</pre>

<h3 id="CSS">CSS</h3>

<pre class="brush: css">.exampleText {
  writing-mode: vertical-rl;
  background-color: yellow;
  block-size: 200px;
}</pre>

<p>{{EmbedLiveSample("Example")}}</p>

<h2 id="说明">说明</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">说明</th>
   <th scope="col">状态</th>
   <th scope="col">注释</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>
    <p>{{SpecName("CSS Logical Properties", "#logical-dimension-properties", "block-size")}}</p>

    <p> </p>
   </td>
   <td>{{Spec2("CSS Logical Properties")}}</td>
   <td>初始定义</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性 </h2>

<div class="hidden">本页面的兼容性表来自于结构型数据,如果你想为此出一份力,请转到<a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> ,然后给我们发送pull请求。</div>

<p>{{Compat("css.properties.block-size")}}</p>

<h2 id="相关链接">相关链接</h2>

<ul>
 <li>The mapped physical properties: {{cssxref("width")}} and {{cssxref("height")}}</li>
 <li>{{cssxref("writing-mode")}}</li>
</ul>