CSS offset-position 属性
示例
指定元素的初始位置为右下角
#square {
width: 60px;
height: 60px;
background: blue;
offset-position: bottom right;
offset-path: ray(45deg);
}
自己动手试一试 »
更多“自己尝试”的例子见下文。
定义和用法
offset-position
属性指定元素沿路径的初始位置。
offset-position
的值决定了元素在沿 offset 路径移动时的初始放置位置,前提是 offset-path
函数没有指定自己的起始位置。
默认值 | normal |
---|---|
继承 | no |
可动画 | 是。 阅读关于 可动画属性 的内容 |
版本 | CSS3 |
JavaScript 语法 | object.style.offsetPosition="auto" |
浏览器支持
表中的数字指定了完全支持该属性的第一个浏览器版本。
属性 | |||||
---|---|---|---|---|---|
offset-position | 116 | 116 | 122 | 16 | 102 |
CSS 语法
offset-position: auto|normal|position|initial|inherit;
属性值
值 | 描述 |
---|---|
normal | 将偏移起始位置设置为包含块的 50% 50%。 这是默认值。 |
auto | 将偏移起始位置设置为元素框的左上角。 |
position | 使用 x/y 坐标指定位置,将元素放置在其框的边缘相对。 位置可以使用一到四个值定义 |
initial | 将此属性设置为其默认值。阅读关于initial |
inherit | 从其父元素继承此属性。阅读关于inherit |
更多示例
示例
查看不同的偏移起始位置
#square1 {
width: 40px;
height: 40px;
background: pink;
text-align:center;
offset-position: bottom right;
offset-path: ray(45deg);
}
#square2 {
width: 40px;
height: 40px;
background: red;
text-align:center;
offset-position: top right;
offset-path: ray(25deg);
}
#square3 {
width: 40px;
height: 40px;
background: yellow;
text-align:center;
offset-position: normal;
offset-path: ray(45deg);
}
#square4 {
width: 40px;
height: 40px;
background: cyan;
text-align:center;
offset-position: auto;
offset-path: ray(95deg);
}
#square5 {
width: 40px;
height: 40px;
background: lavender;
text-align:center;
offset-position: 30% 70%;
offset-path: ray(120deg);
}
自己动手试一试 »
相关页面
HTML SVG 教程:SVG 路径
CSS 教程:CSS 动画
CSS offset 属性:CSS Offset 属性
CSS offset-anchor 属性:CSS Offset-anchor 属性
CSS offset-distance 属性:CSS Offset-distance 属性
CSS offset-path 属性:CSS Offset-path 属性