示例
222
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.book {
position: relative;
width: 200px;
height: 300px;
border: 1px solid #000;
transform-style: preserve-3d;
}
.page {
position: absolute;
width: 100%;
height: 100%;
transform-origin: left;
transform-style: preserve-3d;
backface-visibility: hidden;
transform: perspective(500px) rotateY(0deg);
transition: transform 2s ease-in;
}
.page1 {
background: rgb(250, 225, 193);
}
.page2 {
background: rgb(248, 217, 175);
}
.page3 {
background: rgb(248, 208, 153);
}
.page4 {
background: rgb(252, 203, 134);
}
</style>
</head>
<body>
<div class="book">
<div class="page page4">第四页</div>
<div class="page page3">第三页</div>
<div class="page page2">第二页</div>
<div class="page page1">第一页</div>
底部
</div>
<script>
var pages = document.querySelectorAll('.page')
pages.forEach(v => {
v.onclick = function () {
v.style.transform = 'perspective(500px) rotateY(-180deg)'
}
});
</script>
</body>
</html>
网友评论