JSFiddle - React, Tailwind, and code Playground
HTML
<section class="section-one">
<div class="container">
<h1>Page one</h1>
<button class="button-one">Go To Page Two</button>
</div>
</section>
<section class="section-two">
<div class="container">
<h1>Page two</h1>
<button class="button-two">Go To Page one</button>
</div>
</section>
CSS
body {
text-align: center;
padding: 0;
margin: 0;
}
h1 {
font-size: 50px;
text-align: center
}
section {
padding: 30px 0;
margin: 0;
position: absolute;
overflow: hidden;
height: 100vh;
top: 0;
left: 0;
}
.section-one {
background: #4089A6;
height: 100vh; width: 100%;
z-index: 99;
border-top: 1px solid #4089A6;
border-bottom: 1px solid #4089A6;
}
.section-two {
background: #3bb17c;
height: 2px;
padding: 0;
top: 50vh;
left: 50%;
width: 5px;
display: none;
border-top: 1px solid #3bb17c;
border-bottom: 1px solid #3bb17c;
}
button {
padding: 10px 35px;
border: none;
background: #fff;
font-size: 15px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
border-bottom: 2px solid #ddd;
color: #4089A6;
font-weight: 400;
text-transform: uppercase;
cursor: pointer
}
JavaScript
"use strict";
var section1 = $(".section-one"),
section2 = $(".section-two");
$(".button-one").click(function () {
section1.animate({
'height': '0',
'top': '50vh',
'padding': '0'
}, 300)
.animate({
'width': '2px',
'left': '50%'
}, 900)
.fadeOut(200, function () {
section2.fadeIn(200);
section2.animate({
'width': '100%',
'left': '0'
}, 900);
section2.animate({
'min-height': '100vh',
'top': '0',
'padding-top': '50px',
'padding-bottom': '50px'
}, 300);
});
});
$(".button-two").click(function () {
section2.animate({
'min-height': '0',
'height': '0',
'top': '50vh',
'padding': '0'
}, 300)
.animate({
'width': '2px',
'left': '50%'
}, 900)
.fadeOut(200, function () {
section1.fadeIn(200)
.animate({
'width': '100%',
'left': '0'
}, 900)
.animate({
'height': '100vh',
'top': '0',
'padding-top': '100px',
'padding-bottom': '100px'
}, 300);
});
});