css 动画使用_如何在CSS中使用动画

css 动画使用

使用CSS动画 (Using CSS Animations)

CSS animations add beauty to the webpages and make transitions from one CSS style to the other beautiful.

CSS动画可以使网页更加美观,并可以从一种CSS样式过渡到另一种CSS样式。

To create a CSS animation sequence, we have different sub-properties in the animation property in CSS :

要创建CSS动画序列,我们在CSS的animation属性中具有不同的子属性:

  • animation-delay

    animation-delay

  • animation-direction

    animation-direction

  • animation-duration

    animation-duration

  • animation-iteration-count

    animation-iteration-count

  • animation-name

    animation-name

  • animation-play-state

    animation-play-state

  • animation-timing-function

    animation-timing-function

  • animation-fill-mode

    animation-fill-mode

示例CSS动画序列可在屏幕上移动文本 (Sample CSS animation sequence to move text across the screen)

In the HTML part we will have a div with class container and a h3 with the text Hello World:

在HTML部分,我们将有一个带类containerdiv和一个带文本Hello Worldh3

<div class="container">
    <h3> Hello World ! </h3>
</div>

For the CSS part:

对于CSS部分:

.container {
    /* We will define the width, height and padding of the container */
    /* The text-align to center */
    width: 400px;
    height: 60px;
    padding: 32px;
    text-align: center;

    /* Use the animation `blink` to repeat infinitely for a time period of 2.5s*/
    animation-duration: 2.5s;           
    animation-iteration-count: infinite;
    animation-direction: normal;        
    animation-name: blink;              
    
    /* The same can be written shorthand as     */
    /* --------------------------------------   */
    /* animation: 2.5s infinite normal blink;   */
}
@keyframes blink {
    0%, 100% {              /* Defines the properties at these frames */
        background: #333;
        color: white;
    }

    50% {                   /* Defines the properties at these frames */
        background: #ccc;
        color: black;
        border-radius: 48px;
    }
}

有关CSS动画的更多信息: (More information on CSS Animations:)

翻译自: https://www.freecodecamp.org/news/how-to-use-animations-in-css/

css 动画使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值