JSFiddle - React, Tailwind, and code Playground
HTML
<div class="top">
<label for="c1">div-1</label>
<label for="c2">div-2</label>
<label for="c3">div-3</label>
</div>
<input type="radio" name="page" id="c1" checked>
<div id="div-1" class="page">
<h1>第一页</h1>
</div>
<input type="radio" name="page" id="c2">
<div id="div-2" class="page">
<h1>第二页</h1>
</div>
<input type="radio" name="page" id="c3">
<div id="div-3" class="page">
<h1>第三页</h1>
</div>
CSS
* {
margin: 0;
padding: 0
}
html,body {
height: 100%;
height: 100%;
background: #a3ceff;
overflow: hidden;
}
.top {
width: 100%;
height: 40px;
line-height: 40px;
background: rgba(0, 0, 0, .6);
position: fixed;
z-index: 9;
}
.top label {
display: inline-block;
width: 30%;
color: #fff;
text-align: center;
cursor: pointer;
}
.top label:hover {
background: rgba(0, 0, 0, .4);
}
input {
display: none;
}
h1 {
color: #fff;
padding-top: 20%;
}
.page {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
min-height: 100%;
background: #3C98FF;
text-align: center;
transform: translateY(-100%);
transition: .6s;
}
input[type=radio]:checked + .page {
transform: translateY(0);
animation: fromBtm .4s;
}
@keyframes fromBtm {
from { transform: translateY(10%); }
to { }
}