前言
最近也很久没更新了,带大家看看我之前用CSS写的简易魔法卡旋转效果。
一、首先上效果图
二、代码如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
padding: 0;
margin: 0;
}
body{
display: flex;
height: 100vh;
justify-content: center;
align-items: center;
background-color: black;
/* background: url("img/bbbb.jfif"); */
}
.fabox{
position: absolute;
width: 700px;
height: 700px;
animation: fa;
animation-duration: 50s;
animation-timing-function:cubic-bezier(0.6, 0.6, 0, 0.01);
animation-iteration-count: infinite;
background: url("img/666.png") no-repeat center;
background-size: 100% 100%;
flex-basis: 700px;
transform:rotate(0deg);
}
.card_box{
position:relative;
left: 230px;
top: 150px;
height:425px;
width: 250px;
animation: card_box;
animation-duration: 10s;
animation-timing-function:cubic-bezier(0.2, 0.56, 0.79, 0.48);
animation-iteration-count: infinite;
transform-style: preserve-3d;
box-shadow: 0px 0px 14px 1px rgb(133 133 133);;
transform:rotateX(0deg) rotateY(360deg)
}
.card_back{
position:absolute;
display: inline-block;
height: 100%;
width: 100%;
background: url("img/back.jpg") no-repeat center;
background-size: 100% 100%;
transform:translateZ(1px);
border-radius: 5px;
box-shadow: 0px 0px 1px 1px rgba(136, 136, 136, 0.5);
}
.card_style{
position:absolute;
display: inline-block;
height: 100%;
width: 100%;
background: url("img/q2.png") no-repeat center;
background-size: 100% 100%;
border-radius: 5px;
box-shadow: 0px 0px 1px 1px rgba(136, 136, 136, 0.5);
}
.bbox{
position: relative;
perspective: 800px;
height: 700px;
width: 700px;
}
@keyframes fa{
0%{
transform:rotate(0deg);
}
100%{
transform:rotate(360deg);
}
}
@keyframes card_box{
0%{
transform:rotateX(0deg) rotateY(360deg)
}
100%{
transform:rotateX(0deg) rotateY(0deg)
}
}
</style>
</head>
<body>
<div class="bbox">
<div class="fabox"></div>
<div class="card_box">
<span class="card_back"></span>
<span class="card_style"></span>
</div>
</div>
</body>
</html>