动画(animation)

  • 可通过设置多个节点来精准控制一个或一组动画,常用来实现复杂的动画效果,
    相比于过渡,动画可以实现更多变化,更多控制,连续自动播放等效果

基本使用

  • 制作动画分为两步:
  • 1.先定义动画序列

用keyframes来定义动画

@keyframes 动画名称{
0%{
		width:100px
	}
100%{
		width:200px
	}
}

  • 0%是动画的开始,100%是动画的完成,这样的规则就是动画序列
    可以定义任意多的样式容易多的次数
    请用百分比(整数)来规定变化发生的事件,

  • 2.再使用(调用)动画
  • 口诀:谁使用谁调用
  • 语法:
    animation-name: 动画名称
    animation-duration:动画持续时间单位秒

常用属性

属性描述
@keyframes规定动画
animation所有动画的简写属性,除了animation-play-state属性
animation-name规定@keyframes动画的名称(必须)
animation-duration规定动画完成一个周期所花费的秒或毫秒,默认是0(必须)
animation-timing-funcion规定动画的曲线, 默认是ease
animation-delay规定动画何时开始,默认是0
animation-iteration-count规定动画的播放次数,默认是1,还有infinite(无限)
animation-direction规定动画是否在下一周期逆向播放,默认是normal,alternate逆播放
animation-play-state规定动画是否正在运行或者暂停,默认是running 还有 paused(暂停)
animation-fill-mode规定动画结束后的状态,保持forwards,回到起始backwards


简写方法

  • 语法:
    animation:名称 持续事件 运动曲线 何时开始 播放次数 是否反方向 动画起始或结束的状态
  • 注意:
    1、空格隔开,只需要用到默认值可以简写
    2、简写属性里面不包含animation-play-state
    3、暂停动画:animation-play-state:puased; 经常和鼠标经过等其他配合使用


热点图案例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<style>
    .subject{
        position: relative;
        width: 800px;
        height: 675px;
        background: url("timg.jpg") no-repeat;
        background-size: 800px 675px;
        margin: 0 auto;
    }
    .map{
        position: absolute;
        top: 240px;
        right: 220px;
    }
    .map .dian{
        width: 8px;
        height: 8px;
        background-color:blue;
        border-radius: 50%;
    }
    .map div[class^=ripple]{
        position: absolute;
        top: 50%;
        left: 50%;
        transform:translate(-50%,-50%);
        width: 8px;
        height: 8px;
        /*background-color: black;*/
        box-shadow: 0 0 12px blue;
        border-radius: 50%;
        animation: move 1s linear infinite;
    }
    .map div:nth-child(2){
        animation-delay:0.3s
    }
    .map div:nth-child(3){
        animation-delay:0.6s
    }
    .map div:nth-child(4){
        animation-delay:0.9s
    }
    .as{
        top: 534px;
        right: 141px;
    }
    @keyframes move{
        0%{}
        50%{
            width: 30px;
            height: 30px;
            opacity: 0.7;
        }
        100%{
            width: 70px;
            height: 70px;
            opacity: 0;
        }
    }
</style>
<body>
    <div class="subject">
        <div class="map">
            <div class="dian"></div>
            <div class="ripple1"></div>
            <div class="ripple2"></div>
            <div class="ripple3"></div>
        </div>
        <div class="map as">
            <div class="dian"></div>
            <div class="ripple1"></div>
            <div class="ripple2"></div>
            <div class="ripple3"></div>
        </div>
    </div>
</body>
</html>

  • 案例所需素材,注意路径和名字

在这里插入图片描述


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值