CSS(五):动画
- animation-name
动画名称
语法:animation-name:none|
元素所定义的动画名称,必须与规则@keyframes配合使用,因为动画名称由@keyframes定义。
- @keyframes
语法:
@keyframes
[from|to|
}
被称为关键帧,其类似于Flash中的关键帧。在CSS3中其主要以“@keyframes”开头,后面紧跟着是动画名称加上一对花括号“{…}”,括号中就是一些不同时间段样式规则。
<span style="color: #008080;">1</span> <span style="color: #000000;">/*定义一个名为"fromLeftToRight"的向右移动的动画*/ </span><span style="color: #008080;">2</span> <span style="color: #000000;">@keyframes fromLeftToRight{ </span><span style="color: #008080;">3</span> <span style="color: #000000;"> from{margin:0;} </span><span style="color: #008080;">4</span> <span style="color: #000000;"> to{margin:100px;} </span><span style="color: #008080;">5</span> }
- animation-duration
设置动画的持续时间
语法:animation-duration:
<span style="color: #008080;">1</span> <span style="color: #000000;">/*给div一个名为"fromLeftToRight"的动画效果,并持续一秒时间*/ </span><span style="color: #008080;">2</span> <span style="color: #000000;">div{ </span><span style="color: #008080;">3</span> <span style="color: #000000;"> animation-name:fromLeftToRight; </span><span style="color: #008080;">4</span> <span style="color: #000000;"> animation-duration:1s; </span><span style="color: #008080;">5</span> }
- animation-timing-function
动画的过渡速度类型
语法:animation-timing-function:ease|linear|ease-in|ease-out|ease-in-out
<span style="color: #008080;">1</span> <span style="color: #000000;">/*给div一个名为"fromLeftToRight"的动画效果,持续一秒时间,并且过渡类型为ease-in*/ </span><span style="color: #008080;">2</span> <span style="color: #000000;">div{ </span><span style="color: #008080;">3</span> <span style="color: #000000;"> animation-name:fromLeftToRight; </span><span style="color: #008080;">4</span> <span style="color: #000000;"> animation-duration:1s; </span><span style="color: #008080;">5</span> <span style="color: #000000;"> animation-timing-function:ease-in; </span><span style="color: #008080;">6</span> }
- animation-delay
设置动画的延迟时间
语法:animation-delay:
<span style="color: #008080;">1</span> /*<span style="color: #000000;">给div一个名为"fromLeftToRight"的动画效果,延迟一秒后执行*/ </span><span style="color: #008080;">2</span> <span style="color: #000000;">div{ </span><span style="color: #008080;">3</span> <span style="color: #000000;"> animation-name:fromLeftToRight; </span><span style="color: #008080;">4</span> <span style="color: #000000;"> animation-duration:1s; </span><span style="color: #008080;">5</span> <span style="color: #000000;"> animation-timing-function:ease-in; </span><span style="color: #008080;">6</span> <span style="color: #000000;"> animation-delay: 1s; </span><span style="color: #008080;">7</span> }
- animation-iteration-count
设置动画的执行次数
语法:animation-iteration-count: infinite|
infinite表示无限次数
<span style="color: #008080;">1</span> /*<span style="color: #000000;">给div一个名为"fromLeftToRight"的动画效果,执行两次后停止*/ </span><span style="color: #008080;">2</span> <span style="color: #000000;">div{ </span><span style="color: #008080;">3</span> <span style="color: #000000;"> animation-name:fromLeftToRight; </span><span style="color: #008080;">4</span> <span style="color: #000000;"> animation-duration:1s; </span><span style="color: #008080;">5</span> <span style="color: #000000;"> animation-timing-function:ease-in; </span><span style="color: #008080;">6</span> <span style="color: #000000;"> animation-iteration-count: 2; </span><span style="color: #008080;">7</span> }
- animation-direction
设置动画在循环中是否按照相反顺序执行
语法:animation-direction: normal|reverse|alternate|alternate-reverse
说明:
normal:正常方向
reverse:反方向运行
alternate:动画先正常运行再反方向运行,并持续交替运行
alternate-reverse:动画先反运行再正方向运行,并持续交替运行
<span style="color: #008080;">1</span> <span style="color: #000000;">/*给div一个名为"fromLeftToRight"的动画效果,并且反复运行*/ </span><span style="color: #008080;">2</span> <span style="color: #000000;">div{ </span><span style="color: #008080;">3</span> <span style="color: #000000;"> animation-name:fromLeftToRight; </span><span style="color: #008080;">4</span> <span style="color: #000000;"> animation-duration:1s; </span><span style="color: #008080;">5</span> <span style="color: #000000;"> animation-timing-function:ease-in; </span><span style="color: #008080;">6</span> <span style="color: #000000;"> animation-iteration-count: infinite; </span><span style="color: #008080;">7</span> <span style="color: #000000;"> animation-direction: alternate; </span><span style="color: #008080;">8</span> }
- animation-fill-mode
设置动画开始结束的状态
语法:animation-fill-mode: none|forwards|backwards|both
说明:
none:默认值。不设置动画的状态
forwards:设置对象状态为动画结束时的状态
backwards:设置对象状态为动画开始时的状态
both:设置对象状态为动画结束或开始的状态
<span style="color: #008080;">1</span> <span style="color: #000000;">/*给div一个名为"fromLeftToRight"的动画效果,并且动画结束后元素位于动画结束时的位置*/ </span><span style="color: #008080;">2</span> <span style="color: #000000;">div{ </span><span style="color: #008080;">3</span> <span style="color: #000000;"> animation-name:fromLeftToRight; </span><span style="color: #008080;">4</span> <span style="color: #000000;"> animation-duration:1s; </span><span style="color: #008080;">5</span> <span style="color: #000000;"> animation-timing-function:ease-in; </span><span style="color: #008080;">6</span> <span style="color: #000000;"> animation-iteration-count: 3; </span><span style="color: #008080;">7</span> <span style="color: #000000;"> animation-fill-mode: forwards; </span><span style="color: #008080;">8</span> }
- animation-play-state
设置动画的播放状态
语法:animation-play-state: running|paused
<span style="color: #008080;"> 1</span> <span style="color: #000000;">/*给div一个名为"fromLeftToRight"的动画效果,并且当div处于hover状态时暂停动画*/ </span><span style="color: #008080;"> 2</span> <span style="color: #000000;">div{ </span><span style="color: #008080;"> 3</span> <span style="color: #000000;"> animation-name:fromLeftToRight; </span><span style="color: #008080;"> 4</span> <span style="color: #000000;"> animation-duration:1s; </span><span style="color: #008080;"> 5</span> <span style="color: #000000;"> animation-timing-function:ease-in; </span><span style="color: #008080;"> 6</span> <span style="color: #000000;"> animation-iteration-count: infinite; </span><span style="color: #008080;"> 7</span> <span style="color: #000000;">} </span><span style="color: #008080;"> 8</span> <span style="color: #000000;">div:hover{ </span><span style="color: #008080;"> 9</span> <span style="color: #000000;"> animation-play-state: paused; </span><span style="color: #008080;">10</span> }
- animation
动画的简写属性
语法:
animation:[ animation-name ] || [ animation-duration ] || [ animation-timing-function ] || [ animation-delay ] || [animation-iteration-count ] || [ animation-direction ] ||

Outils d'IA chauds

Undresser.AI Undress
Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover
Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool
Images de déshabillage gratuites

Clothoff.io
Dissolvant de vêtements AI

AI Hentai Generator
Générez AI Hentai gratuitement.

Article chaud

Outils chauds

Bloc-notes++7.3.1
Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)

L'article traite du HTML & lt; Progress & GT; élément, son but, son style et ses différences par rapport au & lt; mètre & gt; élément. L'objectif principal est de l'utiliser & lt; Progress & gt; pour l'achèvement des tâches et & lt; mètre & gt; pour stati

HTML convient aux débutants car il est simple et facile à apprendre et peut rapidement voir les résultats. 1) La courbe d'apprentissage de HTML est fluide et facile à démarrer. 2) Il suffit de maîtriser les balises de base pour commencer à créer des pages Web. 3) Flexibilité élevée et peut être utilisée en combinaison avec CSS et JavaScript. 4) Les ressources d'apprentissage riches et les outils modernes soutiennent le processus d'apprentissage.

L'article traite du HTML & lt; Datalist & GT; élément, qui améliore les formulaires en fournissant des suggestions de saisie semi-automatique, en améliorant l'expérience utilisateur et en réduisant les erreurs. COMMANDE COMPRES: 159

L'article traite du HTML & lt; mètre & gt; élément, utilisé pour afficher des valeurs scalaires ou fractionnaires dans une plage, et ses applications courantes dans le développement Web. Il différencie & lt; mètre & gt; De & lt; Progress & gt; et ex

L'article traite de la balise Meta de la fenêtre, essentielle pour la conception Web réactive sur les appareils mobiles. Il explique comment une utilisation appropriée garantit une mise à l'échelle optimale du contenu et une interaction utilisateur, tandis que la mauvaise utilisation peut entraîner des problèmes de conception et d'accessibilité.

L'article traite du & lt; iframe & gt; L'objectif de Tag dans l'intégration du contenu externe dans les pages Web, ses utilisations courantes, ses risques de sécurité et ses alternatives telles que les balises d'objet et les API.

HTML définit la structure Web, CSS est responsable du style et de la mise en page, et JavaScript donne une interaction dynamique. Les trois exercent leurs fonctions dans le développement Web et construisent conjointement un site Web coloré.

Anexampleofastartingtaginhtmlis, qui abinginsaparagraph.startingtagsaressentialtinhtmlastheyinitiateelements, définit les éventualités, et la faculté de réduction des pages et de la construction de la création.
