效果静态图,就是一个小红块在框里面运动,经过的地方,文本为白色,背景为红色
下面时很low的代码,之所以low是因为还有很多地方要改
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.box{
position: relative;
display: inline-block;
margin: 50px;
width: 50px;
height: 50px;
border: 1px solid #000;
}
.box .item,
.box .move{
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
.line{
display: flex;
}
span{
width: 25px;
height: 25px;
text-align: center;
line-height: 25px;
}
.move span{
position: absolute;
overflow: hidden;
background-color: red;
color: #fff;
}
.move .item_1{
right: 50%;
bottom: 50%;
animation: move_1 2s infinite;
}
.move .item_2{
left: 50%;
bottom: 50%;
animation: move_2 2s infinite;
}
.move .item_4{
left: 50%;
top: 50%;
animation: move_3 2s 0.5s infinite;
}
.move .item_3{
top: 50%;
right: 50%;
animation: move_4 2s 1s infinite;
}
@keyframes move_1
{
0% {
width: 25px;
height: 25px;
}
25% {
width: 0;
height: 25px;
}
50%{
width: 0;
height: 0;
}
75%{
width: 25px;
height: 0;
}
100%{
width: 25px;
height: 25px;
}
}
@keyframes move_2
{
0% {
width: 0;
height: 25px;
}
25% {
width: 25px;
height: 25px;
}
50%{
width: 25px;
height: 0;
}
75%{
width: 0;
height: 0;
}
100%{
width: 0;
height: 25px;
}
}
@keyframes move_3
{
0% {
width: 25px;
height: 0;
}
25% {
width: 25px;
height: 25px;
}
50%{
width: 0;
height: 25px;
}
75%{
width: 0;
height: 0;
}
100%{
width: 25px;
height: 0;
}
}
@keyframes move_4
{
0% {
width: 0;
height: 25px;
}
25% {
width: 25px;
height: 25px;
}
50%{
width: 25px;
height: 0;
}
75%{
width: 0;
height: 0;
}
100%{
width: 0;
height: 25px;
}
}
</style>
</head>
<body>
<div class="box">
<div class="item">
<div class="line">
<span class="item_1">吉</span>
<span class="item_2">祥</span>
</div>
<div class="line">
<span class="item_3">如</span>
<span class="item_4">意</span>
</div>
</div>
<div class="move">
<div class="line">
<span class="item_1">吉</span>
<span class="item_2">祥</span>
</div>
<div class="line">
<span class="item_3">如</span>
<span class="item_4">意</span>
</div>
</div>
</div>
</body>
</html>