CSS3中的3D变换实现图片前后翻转效果
2019年08月28日
771
CSS3中的3D变换实现图片前后翻转效果


html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
#box{
width: 303px;
height: 301px;
background-color: skyblue;
margin: 30px auto 0;
overflow: hidden;
}
#box:hover{
/*动画*/
animation: mymove 2s linear;
}
#box .front{
width: 303px;
height: 301px;
background-image: url(images/bg.png);
background-repeat: no-repeat;
background-position: 0 0;
}
#box .backface{
width: 303px;
height: 301px;
background-image: url(images/bg.png);
background-repeat: no-repeat;
background-position:-302px 0;
}
@keyframes mymove{
from{
transform: rotateY(0deg);
}
to{
transform: rotateY(180deg);
}
}
</style>
</head>
<body>
<div id="box">
<div class="front"></div>
<div class="backface"></div>
</div>
</body>
</html>
