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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
| <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewprot" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
<title>文字飞入飞出案例</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
body{
width: 100vw;
height: 100vh;
overflow: hidden;
}
.buttonWrapper{
width: 100vw;
height: 50px;
display: flex;
justify-content: space-between;
align-items: stretch;
}
.buttonWrapper input{
flex-grow: 1;
text-align: center;
font: 30px/50px "微软雅黑";
font-weight: bold;
color: #0E2D5F;
text-shadow: 0px 0px 2px goldenrod;
/*line-height: 50px;*/
}
.textWrapper{
position: relative;
width: 100vw;
height: 100px;
border: 1px solid black;
line-height: 100px;
}
.textWrapper div{
position: absolute;
width: 100%;
height: 100%;
text-align: center;
transition: all 0.5s ease;
}
.textWrapper div:first-child{
transform: translate(-1000px,500px) rotate(720deg);
}
.textWrapper.active div:first-child{
transform: translate(0,0) rotate(0);
}
.textWrapper.active div:last-child {
transform: translateX(1000px);
}
</style>
</head>
<body>
<div class="buttonWrapper">
<input type="button" name="" id="" value="飞入" />
<input type="button" name="" id="" value="飞出" />
</div>
<div class="textWrapper">
<div>我要测试</div>
<div>努力学习中</div>
</div>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("input").eq(0).on('click',function () {
$(".textWrapper").addClass('active');
});
$("input").eq(1).on('click',function () {
$(".textWrapper").removeClass('active');
});
});
</script>
</body>
</html>
|