上图加了一下代码之后的效果如下
transform-style: preserve-3d;/让父盒子里面的子盒子以3D效果来显示/
鼠标经过旋转
transition: all 5s linear;
设置了section:hover {transform: rotateY(360deg); }
鼠标经过旋转后,还要加这一句transition: all 5s linear;
图片才会动起来 这里面的all是可以省略的 all是默认值
<!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>
body {
perspective: 1000px;
}
section {
width: 300px;
height: 200px;
margin: 100px auto;
background; url(images/img-1.jpg) no-repeat;
background-size: cover;
position: relative;
transform-style: preserve-3d;/*让父盒子里面的子盒子以3D效果来显示*/
transition: all 5s linear; /*设置了section:hover {transform: rotateY(360deg); }鼠标经过旋转后,还要加这一句图片才会动起来 这里面的all是可以省略的 all是默认值*/}
section:hover {
transform: rotateY(360deg);
}
section div {
width: 100%;
height: 100%;
background: url(images/dog.gif) no-repeat;
background-size: cover;
position: absolute;
top: 0;
left: 0;
}
section div:nth-child(1) {
transform: rotateY(0deg) translateZ(400px);/* Z 是旋转轮播图转轴半径,尺寸是不变的*/
}
section div:nth-child(2) {
transform: rotateY(60deg) translateZ(400px);
}
section div:nth-child(3) {
transform: rotateY(120deg) translateZ(400px);
}
section div:nth-child(4) {
transform: rotateY(180deg) translateZ(400px);
}
section div:nth-child(5) {
transform: rotateY(240deg) translateZ(400px);
}
section div:nth-child(6) {
transform: rotateY(300deg) translateZ(400px);
}
</style>
</head>
<body>
<section>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section>
</body>
</html>
网友评论