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/shape-margin/index.html | 121 ++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 files/zh-cn/web/css/shape-margin/index.html (limited to 'files/zh-cn/web/css/shape-margin') diff --git a/files/zh-cn/web/css/shape-margin/index.html b/files/zh-cn/web/css/shape-margin/index.html new file mode 100644 index 0000000000..3b3ea4ef4d --- /dev/null +++ b/files/zh-cn/web/css/shape-margin/index.html @@ -0,0 +1,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 +--- +
{{CSSRef}}
+ +

CSS 属性 shape-margin 用于设定由{{cssxref("shape-outside")}}创建的CSS形状的外边距。

+ +
{{EmbedInteractiveExample("pages/css/shape-margin.html")}}
+ + + +

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

+ +

语法

+ +
/* <length> values */
+shape-margin: 10px;
+shape-margin: 20mm;
+
+/* <percentage> value */
+shape-margin: 60%;
+
+/* Global values */
+shape-margin: inherit;
+shape-margin: initial;
+shape-margin: unset;
+
+ +

+ +
+
<length-percentage>
+
使用{{cssxref("<length>")}}值,或者相对于元素容纳块的{{cssxref("<percentage>")}}值来设定形状的外边距。
+
+ +

正式语法

+ +
{{csssyntax}}
+ +

范例

+ +

HTML

+ +
<section>
+<div class="shape"></div>
+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.</section>
+ +

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;
+}
+ +

Result

+ +

+ +

规范

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS Shapes', '#shape-margin-property', 'shape-margin')}}{{Spec2('CSS Shapes')}}Initial definition
+ +

{{cssinfo}}

+ +

浏览器兼容性

+ +
+ + +

{{Compat("css.properties.shape-margin")}}

+
+ +

参见

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