shape-margin
CSS
property sets a margin for a CSS shape created using
shape-outside
.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
The margin lets you adjust the distance between the edges of the shape (the float element ) and the surrounding content.
/* <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>
<length>
value or to a
<percentage>
of the width of the element's containing block.
| 初始值 |
0
|
|---|---|
| 适用于 | floats |
| 继承 | no |
| 百分比 | refer to the width of the containing block |
| 计算值 | as specified, but with relative lengths converted into absolute lengths |
| 动画类型 | a length , percentage or calc(); |
<length-percentage>where
<length-percentage> = <length> | <percentage>
<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>
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;
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Shapes Module Level 1
The definition of 'shape-margin' in that specification. |
候选推荐 | 初始定义 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
shape-margin
|
Chrome 完整支持 37 | Edge 完整支持 79 |
Firefox
完整支持
62
|
IE 不支持 No | Opera 完整支持 24 | Safari 完整支持 10.1 | WebView Android 完整支持 37 | Chrome Android 完整支持 37 |
Firefox Android
完整支持
62
|
Opera Android 完整支持 24 | Safari iOS 完整支持 10.3 | Samsung Internet Android 完整支持 3.0 |
完整支持
不支持
用户必须明确启用此特征。
要求使用供应商前缀或不同名称。