- CSS 教程
- CSS - 首頁
- CSS - 路線圖
- CSS - 簡介
- CSS - 語法
- CSS - 選擇器
- CSS - 包含
- CSS - 測量單位
- CSS - 顏色
- CSS - 背景
- CSS - 字型
- CSS - 文字
- CSS - 圖片
- CSS - 連結
- CSS - 表格
- CSS - 邊框
- CSS - 塊級邊框
- CSS - 內聯邊框
- CSS - 外邊距
- CSS - 列表
- CSS - 內邊距
- CSS - 游標
- CSS - 輪廓
- CSS - 尺寸
- CSS - 捲軸
- CSS - 塊級內聯
- CSS - 下拉選單
- CSS - 可見性
- CSS - 溢位
- CSS - Clearfix
- CSS - 浮動
- CSS - 箭頭
- CSS - 調整大小
- CSS - 引號
- CSS - 排序
- CSS - 定位
- CSS - 連字元
- CSS - 懸停
- CSS - 顯示
- CSS - 聚焦
- CSS - 縮放
- CSS - 位移
- CSS - 高度
- CSS - 連字元字元
- CSS - 寬度
- CSS - 不透明度
- CSS - Z-Index
- CSS - 底部
- CSS - 導航欄
- CSS - 覆蓋層
- CSS - 表單
- CSS - 對齊
- CSS - 圖示
- CSS - 圖片庫
- CSS - 註釋
- CSS - 載入器
- CSS - 屬性選擇器
- CSS - 組合器
- CSS - 根元素
- CSS - 盒模型
- CSS - 計數器
- CSS - 剪裁
- CSS - 書寫模式
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - 內嵌
- CSS - 隔離
- CSS - 滾動溢位
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - 指標事件
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - 最大塊級尺寸
- CSS - 最小塊級尺寸
- CSS - 混合模式
- CSS - 最大內聯尺寸
- CSS - 最小內聯尺寸
- CSS - 偏移量
- CSS - 重音色
- CSS - 使用者選擇
- CSS 高階
- CSS - 網格
- CSS - 網格佈局
- CSS - Flexbox
- CSS - 可見性
- CSS - 定位
- CSS - 層
- CSS - 偽類
- CSS - 偽元素
- CSS - @規則
- CSS - 文字效果
- CSS - 分頁媒體
- CSS - 列印
- CSS - 佈局
- CSS - 驗證
- CSS - 圖片精靈
- CSS - !important
- CSS - 資料型別
- CSS3 教程
- CSS3 - 教程
- CSS - 圓角
- CSS - 邊框圖片
- CSS - 多重背景
- CSS - 顏色
- CSS - 漸變
- CSS - 盒陰影
- CSS - 盒裝飾中斷
- CSS - 游標顏色
- CSS - 文字陰影
- CSS - 文字
- CSS - 2D 變換
- CSS - 3D 變換
- CSS - 過渡
- CSS - 動畫
- CSS - 多列
- CSS - 盒尺寸
- CSS - 工具提示
- CSS - 按鈕
- CSS - 分頁
- CSS - 變數
- CSS - 媒體查詢
- CSS - 函式
- CSS - 數學函式
- CSS - 遮罩
- CSS - 形狀
- CSS - 樣式圖片
- CSS - 特異性
- CSS - 自定義屬性
- CSS 響應式
- CSS RWD - 簡介
- CSS RWD - 視口
- CSS RWD - 網格檢視
- CSS RWD - 媒體查詢
- CSS RWD - 圖片
- CSS RWD - 影片
- CSS RWD - 框架
- CSS 工具
- CSS - PX 到 EM 轉換器
- CSS - 顏色選擇器和動畫
- CSS 資源
- CSS - 有用資源
- CSS - 討論
CSS - offset-position 屬性
CSS 屬性offset-position用於指定元素沿著路徑的起始位置。
它通常與offset-path屬性結合使用,以建立運動效果。
如果offset-path函式沒有定義其自身的起始位置,則使用offset-position來確定元素的初始位置。
包含與偏移相關的功能(如offset-anchor、offset-distance和offset-path)的運動系統也包含offset-position屬性。
這些屬性一起提供了沿著指定路徑的各種運動效果。
可能的值
offset-position屬性接受以下值列表。
normal - 此選項將元素放置在相對於包含塊的 (50%, 50%) 位置,表示它沒有初始偏移位置。
auto - 此值表示元素盒的左上角是初始偏移位置,這是預設選項。
<length-percentage> - offset-position 屬性使用 x/y 座標來確定元素相對於其盒邊緣的位置,值範圍從一到四,分別表示水平和垂直位置。
應用於
可變換元素
語法
offset-position = normal | auto | <position>
CSS offset-position - 初始化 offset-path 的 offset-position
以下示例演示了offset-position屬性的用法。
<html>
<head>
<style>
.container {
width: 80%;
height: 400px;
position: relative;
overflow: hidden;
background-color: #c6d8f5;
}
.object {
width: 50px;
height: 50px;
background-color: #1169f7;
position: absolute;
border-radius: 20%;
offset-path: path("M 50, 200 C 50, 100 250, 100 250, 200 S 450, 300 450, 200");
offset-position: top 10%;
animation: moveObject 5s linear infinite;
}
@keyframes moveObject {
0% {
offset-distance: 0%;
}
100% {
offset-distance: 100%;
}
}
</style>
</head>
<body>
<div class="container">
<div class="object"></div>
</div>
</body>
</html>
CSS offset-position - 比較偏移位置
以下示例演示了offset-position屬性的各種偏移位置的用法。
<html>
<head>
<style>
.container {
position: relative;
height: 300px;
background-color: #f0f0f0;
margin: 50px auto;
padding: 20px;
}
.box {
width: 90px;
height: 90px;
background-color: #3477eb;
position: absolute;
border-radius: 40%;
animation: moveObject 5s linear infinite;
display: flex;
justify-content: center;
align-items: center;
font-size: 16px;
color: white;
}
@keyframes moveObject {
0% {
offset-distance: 0%;
}
100% {
offset-distance: 100%;
}
}
.box-normal::after {
content: "Normal";
}
.box-center::after {
content: "Center";
}
.box-left-top::after {
content: "Left Top";
}
.box-right-bottom::after {
content: "Right Bottom";
}
.box-custom::after {
content: "Custom (30% 70%)";
}
.box-normal {
offset-position: normal;
top: 20px;
left: 20px;
}
.box-center {
offset-position: center;
top: 20px;
left: calc(50% - 25px);
}
.box-left-top {
offset-position: left top;
top: 20px;
left: 20px;
}
.box-right-bottom {
offset-position: right bottom;
bottom: 20px;
right: 20px;
}
.box-custom {
offset-position: 30% 70%;
top: calc(30% - 25px);
left: calc(70% - 25px);
}
</style>
</head>
<body>
<div class="container">
<div class="box box-normal"></div>
<div class="box box-center"></div>
<div class="box box-left-top"></div>
<div class="box box-right-bottom"></div>
<div class="box box-custom"></div>
</div>
</body>
</html>
廣告