CSS3实例: 实现 swap 动画_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:29:34
Original
1505 people have browsed it

CSS3动画的出现,让我的真的非常喜欢,因为他够简单.今天我们来实现一个交换动画,一个笑脸慢慢从远处,回到自己的原来位置的一种效果.这种动画在JS里面也是很多见的.

首先得将HTML结构设计好,一个固定的窗口,然后一个带有黑色背景的笑脸

代码名称

<div><span>☺</span></div>
Copy after login

笑脸居中我们用最新的布局flex来实现,这个也是很好用的属性.之前文章中已经有flex的相关教程,大家不懂的可以看看.

代码名称

div{

width: 200px;

height: 200px;

color: #fff;

border: #eee 2px solid;

}

div > span{

width: 100%;

height: 100%;

position: relative;

background-color: #000;

display: flex;

justify-content: center;

align-items: center;

font-size: 80px;

animation: anims 1s ease-in;

}

然后加入动画,动画是位置的变化,和元素缩放状态的变化,再加入了透明度的变化.

代码名称

@keyframes anims {

0% {

right: 0px;

top: 0;

transform: scale(0);

opacity: 0.2;

}

50%{

top: 0;

right: -300px;

transform: scale(0.5);

opacity: 0.6;

}

90%{

top: 0;

right: -10px;

transform: scale(0.99);

opacity: 0.9;

}

100%{

top: 0;

right:0px;

transform: scale(1);

opacity: 1;

}

}

这样就实现了我们想要的效果,当然自己出现的动态效果,还可以自己来设定.

好了,这就是swap 动画效果.

本文属于吴统威的博客, 微信公众号:bianchengderen,QQ群:186659233 的原创文章,转载时请注明出处及相应链接:http://www.wutongwei.com/front/infor_showone.tweb?id=185 ,欢迎大家传播与分享.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!