一、翻牌效果
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>3D动画</title>
<style type="text/css">
body, div {
padding: 0;
margin: 0;
}
.container {
position: absolute;
top: 50%;
left: 50%;
margin-left: -177.5px;
margin-top: -250px;
width: 355px;
height: 500px;
perspective: 1000px;
}
.out_box {
position: relative;
height: 500px;
width: 355px;
transform-style: preserve-3d;
transition: 0.5s;
backface-visibility: hidden;
}
.out_box div {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
backface-visibility: hidden;
}
.out_box div.front_box {
background: url("puke-back.png") no-repeat;
background-size: 100% 100%;
z-index: 2;
}
.out_box div.back_box {
background: url("puke-k.png") no-repeat;
background-size: 100% 100%;
z-index: 1;
transform: rotateY(180deg);
}
.container:hover .out_box {
transform: rotateY(180deg);
}
.container:hover .back_box {
z-index: 3;
}
</style>
</head>
<body>
<div class="container">
<div class="out_box">
<div class="front_box"></div>
<div class="back_box"></div>
</div>
</div>
</body>
</html>
翻牌效果图
二、钟摆
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
body, div {
margin: 0;
padding: 0;
}
.box {
margin: 20px auto;
width: 120px;
height: 300px;
background: url("zhongbai.png") no-repeat;
/*设置运动的原点为顶部中间的位置,这样动画都围绕这个点来实现运动*/
-webkit-transform-origin: top center;
transform-origin: top center;
/*设置运动的初始位置-->左边旋转45deg位置*/
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
/*设置css3运动动画*/
-webkit-animation: move 1s ease infinite;
animation: move 1s ease infinite;
}
/*设置动画运动的关键帧*/
@-webkit-keyframes move {
0%, 100% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
50% {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}
}
@keyframes move {
0%, 100% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
50% {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
钟摆效果图