要实现该效果,网站正在将内容部分应用translate3d(0, 100%, 0)
,将其转换出屏幕。
事件处理程序将变换设置为translate3d(0, 0%, 0)
以将其转换回屏幕上。
要动画风格的变化转变被用于transition: all 0.7s ease;
由于内容设置为100%的高度,并且没有滚动条,它实际上是一个点击处理程序触发动画。
//1. User clicks the element
$('.website-wrapper').click(function() {
$(".content-section").css("-webkit-transform","translate3d(0, 0%, 0)");
$(".content-section").css("-ms-transform","translate3d(0, 0%, 0)");
$(".content-section").css("transform","translate3d(0, 0%, 0)");
});
//2. Height of Hero-Section goes to 0px with a transform.
html, body {
min-height: 100%;
}
.hero-section {
position: fixed;
top: 0;
left: 0;
bottom: 0;
width: 100%;
height: 100%;
background-color:red;
}
.content-section {
-webkit-transition: all 0.7s ease;
transition: all 0.7s ease;
-webkit-transform: translate3d(0, 100%, 0);
-ms-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
position: fixed;
top: 0;
left: 0;
bottom: 0;
width: 100%;
height: 100%;
background-color:green;
}
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<div class="website-wrapper">
<div class="hero-section"><h1>Hero Section</h1></div>
<div class="content-section"><h1>Content Section</h1></div>
</div>
</body>
</html>
这是两个答案我收到的组合版本。谢谢你的帮忙。 https://codepen.io/stinkytofu3311/pen/VWqYvY – StinkyTofu