Open OPY-bbt opened 4 years ago
利用 transform-style
<!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>
html {
height: 100%;
overflow: hidden;
}
body {
margin: 0;
padding: 0;
perspective: 2px;
transform-style: preserve-3d;
transform-origin: center center;
height: 100%;
overflow-y: scroll;
overflow-x: hidden;
}
.g-container {
position: relative;
height: 150%;
}
.g-container > div {
font-size: 5vw;
position: absolute;
top: 20%;
}
.section-one {
left: 0%;
background: rgba(10, 10, 10, 0.2);
transform: translateZ(-1px);
}
.section-two {
left: 40%;
background: rgba(30, 130, 30, 0.2);
transform: translateZ(-2px);
}
.section-three {
left: 90%;
background: rgba(200, 100, 130, 0.2);
transform: translateZ(-3px);
}
</style>
</head>
<body>
<div class="g-container">
<div class="section-one">translateZ(-1)</div>
<div class="section-two">translateZ(-2)</div>
<div class="section-three">translateZ(-3)</div>
</div>
</body>
</html>
background-attachment:fixed(背景相对于视口固定)