JSFiddle - React, Tailwind, and code Playground

by Shajeer Ahamed

HTML

<ul class="menu">
	<li><a href="/" class="threed">
		Home
		<span class="box">
			<span class="white">Home</span>
			<span class="black">Home</span>
		</span>
	</a></li>
</ul>

CSS

.menu li {
	display: inline-block;
}

.menu li a {
	color: #fff;
	display: block;
	text-decoration: none;
	overflow: visible;
	line-height: 20px;
	font-size: 24px;
	padding: 15px 10px;
}

/* animation domination */
.threed {
	perspective: 200px;
	transition: all .07s linear;
	position: relative;
	cursor: pointer;
}
	/* complete the animation! */
	.threed:hover .box, 
	.threed:focus .box {
		transform: translateZ(-25px) rotateX(90deg);
	}

.box {
	transition: all .3s ease-out;
	transform: translatez(-25px);
	transform-style: preserve-3d;
	pointer-events: none;
	position: absolute;
	top: 0;
	left: 0;
	display: block;
	width: 100%;
	height: 100%;
}

.white {
	transform: rotatex(0deg) translatez(25px);
    background: white;
    color: black;
}

.black {
	transform: rotatex(-90deg) translatez(25px);
	color: white;
    background: black;
}

.white, .black {
	display: block;
	width: 100%;
	height: 100%;
	position: absolute;
	top: 0;
	left: 0;
	padding: 15px 10px;
	pointer-events: none;
	box-sizing: border-box;
}