css小猫笑起来的动画

No.3 - CSS transition 和 CSS transform 配合制作动画

仓库地址

预览地址

资料

文章地址

其实文章地址里面提供的资料已经很不错了!!!(偷懒~

效果

截图

截图

代码实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# html
<div class="container">
<!-- 脸 -->
<div class="face">
<!-- 头发 -->
<div class="hair"></div>
<!-- 眼睛 -->
<div class="eye-wrap">
<div class="eye left">
<div class="eye-circle">
<div class="eye-core"></div>
</div>
<div class="eye-bottom"></div>
<div class="face-red"></div>
</div>
<div class="eye right">
<div class="eye-circle">
<div class="eye-core"></div>
</div>
<div class="eye-bottom"></div>
<div class="face-red"></div>
</div>
</div>
<!-- 鼻子 -->
<div class="nose"></div>
<!-- 嘴巴 -->
<div class="mouth-wrap">
<div class="mouth left"></div>
<div class="mouth right"></div>
</div>
</div>
<!-- 耳朵 -->
<div class="ear-wrap">
<div class="ear left"></div>
<div class="ear right"></div>
</div>
</div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# css 动画部分样式
.face,
.hair,
.face-red,
.eye-bottom,
.ear,
.eye-core,
.mouth{
transition: transform 1s;
}
.face-red{
transition: opacity 1s;
}
.mouth{
transition: border-radius 1s;
}

.face:hover~.ear-wrap .left{
transform-origin: 50%, 100%;
transform: rotate(-30deg);
}
.face:hover~.ear-wrap .right{
transform-origin: 50%, 100%;
transform: rotate(30deg);
}
.face:hover .eye-wrap .eye-bottom{
transform: translateY(-15px);
}

.face:hover .eye-wrap .face-red{
opacity: 1;
}
.face:hover .eye-wrap .eye-core{
transform: scaleX(.8);
}
.face:hover .mouth-wrap .left{
border-radius: 0% 40% 50% 50%;
}
.face:hover .mouth-wrap .right{
border-radius: 0% 40% 50% 50%;
}
.face:hover{
transform: scaleX(.99);
transform: translateY(-6px);
}
.face:hover .hair{
transform: scaleX(.9);
}

Qq: 952822399