html直播点赞特效,CSS3实现红心点赞特效

1.创建html

2. css

.heart {

background: url(http://demo.htmleaf.com/1511/201511131551/images/web_heart_animation.png);

background-position: left;

background-repeat: no-repeat;

height: 100px;

width: 100px;

cursor: pointer;

position: absolute;

left: -14px;

background-size: 2900%;

}

.heart:hover,

.heart:focus {

background-position: right;

}

@-webkit-keyframes heartBlast {

0% {

background-position: left;

}

100% {

background-position: right;

}

}

@keyframes heartBlast {

0% {

background-position: left;

}

100% {

background-position: right;

}

}

.heartAnimation {

display: inline-block;

-webkit-animation-name: heartBlast;

animation-name: heartBlast;

-webkit-animation-duration: .8s;

animation-duration: .8s;

-webkit-animation-iteration-count: 1;

animation-iteration-count: 1;

-webkit-animation-timing-function: steps(28);

animation-timing-function: steps(28);

background-position: right;

}

@-webkit-keyframes dorsyHover {

0% {

-webkit-box-shadow: 0 0 1px 1px #aaa30a;

}

50% {

-webkit-box-shadow: 0 0 1px 1px #fdfbc4;

}

100% {

-webkit-box-shadow: 0 0 1px 1px yellow;

}

}

@-webkit-keyframes dorsyDelete {

0% {

-webkit-transform: rotate(0deg);

}

40% {

-webkit-transform: rotate(10deg);

}

80% {

-webkit-transform: rotate(-10deg);

}

100% {

-webkit-transform: rotate(0deg);

}

}

3.js 点击事件添加类名

4.核心语义

1.backgroundbackground-position: left; (结束为right)

3.animate-duration:1s;(动画运行时间)

4.animation-iteration-count :n / infinite ;(循环次数 n 不限)

5.animation-timing-function: steps(28);

速度曲线,使用三次贝塞尔函数的数学函数来生成速度曲线

参数为steps时:

第一个参数指定了时间函数中的间隔数量(必须是正整数)

第二个参数可选,接受 start 和 end 两个值,指定在每个间隔的起点或是终点发生阶跃变化,默认为 end。

step-start等同于steps(1,start),动画分成1步,动画执行时为开始左侧端点的部分为开始;

step-end等同于steps(1,end):动画分成一步,动画执行时以结尾端点为开始,默认值为end。

steps() 第一个参数 number 为指定的间隔数,即把动画分为 n 步阶段性展示,估计大多数人理解就是keyframes写的变化次数

作者:AstarX

链接:https://www.jianshu.com/p/753c4ea0c18c

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值