css3过度动画网页加载中,加载时有css3过渡动画?

小编典典

您 可以 在页面加载时运行 CSS 动画,而无需使用任何JavaScript;您只需要使用 CSS3关键帧即可 。

让我们看一个例子…

这是仅使用 CSS3 的导航菜单滑入位置的演示:

@keyframes slideInFromLeft {

0% {

transform: translateX(-100%);

}

100% {

transform: translateX(0);

}

}

header {

/* This section calls the slideInFromLeft animation we defined above */

animation: 1s ease-out 0s 1 slideInFromLeft;

background: #333;

padding: 30px;

}

/* Added for aesthetics */ body {margin: 0;font-family: "Segoe UI", Arial, Helvetica, Sans Serif;} a {text-decoration: none; display: inline-block; margin-right: 10px; color:#fff;}

Home

About

Products

Contact

分解…

这里的重要部分是关键帧动画,我们称之为slideInFromLeft…

@keyframes slideInFromLeft {

0% {

transform: translateX(-100%);

}

100% {

transform: translateX(0);

}

}

…这基本上是说:“开始时,标题将离开屏幕的左侧边缘的整个宽度,而结尾将位于适当位置”。

第二部分是调用该slideInFromLeft动画:

animation: 1s ease-out 0s 1 slideInFromLeft;

上面是速记版本,但是为了清楚起见,这里是详细版本:

animation-duration: 1s; /* the duration of the animation */

animation-timing-function: ease-out; /* how the animation will behave */

animation-delay: 0s; /* how long to delay the animation from starting */

animation-iteration-count: 1; /* how many times the animation will play */

animation-name: slideInFromLeft; /* the name of the animation we defined above */

您可以做各种有趣的事情,例如滑动内容或吸引人们注意区域。

2020-05-16

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值