在悬停时为主菜单项设置翻转动画



我有一个演示网站。 如何获得下面给出的参考网站中的菜单悬停效果。我在这里摆弄了一下,但是当我将鼠标悬停在菜单项上时,我没有过渡

参考网站 :- 点击这里

将鼠标悬停在顶部菜单上并查看效果。 我如何获得这种效果?

查看此处的代码,直到我完成

.HTML

<li>
    <div class="header-navigation-item-state-wrapper">
        <div class="white">
                <h4 class="header-white">Collections</h4>
        </div>
        <div class="black">
                <h4 class="header-black">Collections</h4>
        </div>
    </div>
</li>

.CSS

* {
    background:yellow
}
li {
    list-style:none;
}
.header-black {
    background:#000;
    color:#fff;
    padding:10px;
    display:block
}
.black {
    display:none;
}
.header-white {
    background:#fff;
    color:#000;
    padding:10px;
    display:block
}

杰奎里

$(document).ready(function () {
    $("li").mouseenter(function () {
        $(".white").css('display', 'none');
        $(".black").css('display', 'block');
    });
    $("li").mouseleave(function () {
        $(".white").css('display', 'block');
        $(".black").css('display', 'none');
    });
})

您可以按照以下方式使用 3D 效果。

.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;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<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>

您可以根据需要进行更改。
希望对您有所帮助。

最新更新