国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

前端 - css3動畫怎樣對幀的理解?

瀏覽:146日期:2023-07-14 13:39:14

問題描述

第一種:

@keyframes slow {0% { background-position: -0px -291px;}25% { background-position: -602px -0px;}50% { background-position: -302px -291px;}75% { background-position: -151px -291px;}100% { background-position: -0px -291px;} } /*動畫切換的方式是一幀一幀的改變*/-webkit-animation-timing-function: steps(1, start);

第二種:

$spriteWidth: 140px; // 精靈寬度 @keyframes run { 0% { background-position: 0 0; } 100% { background-position: -($spriteWidth * 12) 0; // 12幀 }}#sprite { width: $spriteWidth; height: 144px; background: url('../images/sprite.png') 0 0 no-repeat; animation: run 0.6s steps(12) infinite;}

1,什么叫“一幀一幀的改變”, steps(1, start);該如何理解?2,第二種直接“-($spriteWidth * 12) 0”我就看不懂了,為什么這樣寫?

問題解答

回答1:1. 什么叫“一幀一幀的改變”, steps(1, start);該如何理解?

animation-timing-function 中 steps 的用法參見這篇

steps 詳解

2. 第二種直接“-($spriteWidth * 12) 0”我就看不懂了,為什么這樣寫?

首先顯然這是 Scss 文件(一種 css 預(yù)編譯文件)

定義了一個變量:$spriteWidth

-($spriteWidth * 12) 這句就是一個運(yùn)算呀 => -(140px*12)

回答2:

1: steps(1, start)我在MDN上剛好看到一個解釋

This keyword represents the timing function steps(1, start). Using this timing function, the animation jumps immediately to the end state and stay in that position until the end of the animation.

就是說你的動畫幀一開始就馬上跳到結(jié)束了,所以你看見的是keyframes里面5個幀一幀一幀地切換。如果沒有steps(1, start),就會是一個平滑移動的效果。

2: -($spriteWidth * 12)應(yīng)該是指把你這個動畫分成12幀,每一幀你的背景右移-($spriteWidth * 12)這個長度

標(biāo)簽: CSS
相關(guān)文章:
主站蜘蛛池模板: 泌阳县| 德昌县| 吐鲁番市| 浮山县| 乌拉特中旗| 武宣县| 乡宁县| 深州市| 德钦县| 泗阳县| 商洛市| 谢通门县| 宜宾县| 镶黄旗| 蒲江县| 宜阳县| 兴海县| 平乐县| 新晃| 曲阳县| 古蔺县| 芦山县| 江永县| 淄博市| 惠水县| 集安市| 罗山县| 韩城市| 广丰县| 江陵县| 抚松县| 基隆市| 资阳市| 郧西县| 琼海市| 蓬安县| 怀宁县| 银川市| 舞钢市| 永修县| 邵东县|