shape-margin - CSS(层叠样式表) 编辑
CSS 属性 shape-margin
用于设定由shape-outside
创建的CSS形状的外边距。
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.
这个外边距可以让你调整(浮动元素的)形状边缘与环绕内容之间的距离。
语法
/* <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>
值,或者相对于元素容纳块的<percentage>
值来设定形状的外边距。
正式语法
<length-percentage>where
<length-percentage> = <length> | <percentage>
范例
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
规范
Specification | Status | Comment |
---|---|---|
CSS Shapes Module Level 1 shape-margin | Candidate Recommendation | Initial definition |
初始值 | 0 |
---|---|
适用元素 | floats |
是否是继承属性 | 否 |
Percentages | refer to the width of the containing block |
计算值 | as specified, but with relative lengths converted into absolute lengths |
Animation type | a length, percentage or calc(); |
浏览器兼容性
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.参见
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论