※Please check using Developer tools
DUMMEY
.block {
position: relative;
height: 500px;
margin: 70px auto 0;
}
.box {
position: absolute;
top: 50%;
left: 50%;
width: 500px;
height: 500px;
transform: translate(-50%, -50%);
}
.square {
position: absolute;
width: 51%;
height: 51%;
background-color: #2f2f38;
}
.square.top {
top: 0;
right: 50%;
width: 0;
transition: width 0.7s ease-in-out;
}
.square.bottom {
bottom: 0;
left: 50%;
width: 0;
transition: width 0.7s ease-in-out;
}
.square.left {
top: 50%;
left: 0;
height: 0;
transition: height 0.7s ease-in-out;
}
.square.right {
right: 0;
bottom: 50%;
height: 0;
transition: height 0.7s ease-in-out;
}
.text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 50px;
color: #fff;
transition: 0.8s cubic-bezier(0.82, 0.01, 0.28, 0.99) 0.5s;
opacity: 0;
}
.active .square.top {
width: 50%;
}
.active .square.bottom {
width: 50%;
}
.active .square.left {
height: 50%;
}
.active .square.right {
height: 50%;
}
.active .text {
opacity: 1;
}
@media screen and (max-width:640px){
.block {
height: 300px;
}
.box {
width: 300px;
height: 300px;
}
.active .text {
font-size: 20px;
}
}
$(window).on('load', function(){
$(".block").addClass("active");
});