aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/shape-margin/index.html
blob: 3b3ea4ef4d98dd897d27e0a26748b88dad64acca (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
title: shape-margin
slug: Web/CSS/shape-margin
tags:
  - CSS
  - CSS Property
  - CSS Shapes
  - Reference
  - float
  - margin
  - shape-margin
translation_of: Web/CSS/shape-margin
---
<div>{{CSSRef}}</div>

<p><span class="seoSummary"><a href="/en-US/docs/Web/CSS">CSS</a> 属性 <strong><code>shape-margin</code></strong> 用于设定由{{cssxref("shape-outside")}}创建的CSS形状的外边距。</span></p>

<div>{{EmbedInteractiveExample("pages/css/shape-margin.html")}}</div>



<p>这个外边距可以让你调整(浮动元素的)形状边缘与环绕内容之间的距离。</p>

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

<pre class="brush:css no-line-numbers">/* &lt;length&gt; values */
shape-margin: 10px;
shape-margin: 20mm;

/* &lt;percentage&gt; value */
shape-margin: 60%;

/* Global values */
shape-margin: inherit;
shape-margin: initial;
shape-margin: unset;
</pre>

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

<dl>
 <dt><code>&lt;length-percentage&gt;</code></dt>
 <dd>使用{{cssxref("&lt;length&gt;")}}值,或者相对于元素容纳块的{{cssxref("&lt;percentage&gt;")}}值来设定形状的外边距。</dd>
</dl>

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

<pre class="syntaxbox">{{csssyntax}}</pre>

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

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

<pre class="brush: html">&lt;section&gt;
&lt;div class="shape"&gt;&lt;/div&gt;
We are not quite sure of any one thing in biology; our knowledge of geology
is relatively very slight, and the economic laws of society are
uncertain to every one except some individual who attempts to set them
forth; but before the world was fashioned the square on the hypotenuse
was equal to the sum of the squares on the other two sides of a right
triangle, and it will be so after this world is dead; and the inhabitant
of Mars, if he exists, probably knows its truth as we know it.&lt;/section&gt;</pre>

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

<pre class="brush: css">section {
  max-width: 400px;
}

.shape {
  float: left;
  width: 150px;
  height: 150px;
  background-color: maroon;
  clip-path: polygon(0 0, 150px 150px, 0 150px);
  shape-outside: polygon(0 0, 150px 150px, 0 150px);
  shape-margin: 20px;
}</pre>

<h3 id="Result">Result</h3>

<p><iframe class="live-sample-frame sample-code-frame" frameborder="0" height="250" id="frame_Example" src="https://mdn.mozillademos.org/zh-CN/docs/Web/CSS/shape-margin$samples/Example?revision=1608812" width="500"></iframe></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('CSS Shapes', '#shape-margin-property', 'shape-margin')}}</td>
   <td>{{Spec2('CSS Shapes')}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<p>{{cssinfo}}</p>

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

<div>


<p>{{Compat("css.properties.shape-margin")}}</p>
</div>

<h2 id="参见">参见</h2>

<ul>
 <li><a href="/en-US/docs/Web/CSS/CSS_Shapes">CSS Shapes</a></li>
 <li><a href="/en-US/docs/Web/CSS/CSS_Shapes/Overview_of_CSS_Shapes">Overview of CSS Shapes</a></li>
 <li>{{cssxref("shape-outside")}}</li>
 <li>{{cssxref("shape-image-threshold")}}</li>
 <li>{{cssxref("&lt;basic-shape&gt;")}}</li>
</ul>