我正在尝试创建导航栏菜单,其中文字在悬停时翻转。
这是我迄今为止尝试的代码,并嵌入了视频,展示了我正在努力实现的最终效果。
我无法想到一种方法来使文本在鼠标悬停时向上移动并从底部返回到起始位置的动画效果。
这是我迄今为止尝试的代码,并嵌入了视频,展示了我正在努力实现的最终效果。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
background: transparent;
font-weight: normal;
text-decoration: none;
outline: none;
box-sizing: border-box;
}
.wrapper {
width: 90%;
margin: 0 auto;
max-width:1100px;
}
header {
height: 100px;
padding: 20px 0;
}
header nav {}
header nav ul {
list-style: none;
display: flex;
justify-content: space-between;
}
header nav ul li {
font-size: 23px;
position: relative;
}
header nav ul li a {
position: absolute;
}
header nav ul li a:hover {
animation: flip 2s ease infinite;
}
div.video iframe {
margin-top: 30px;
}
@keyframes flip {
0% {
top: 0;
}
25% {
top: -50px;
}
50% {
top: -100px;
}
75% {
top: -150px;
}
100% {
top: 0;
}
}
</style>
</head>
<body>
<header>
<nav>
<section class="wrapper">
<ul>
<li><a href="#">About</a></li>
<li><a href="#">Project</a></li>
<li><a href="#">Resume</a></li>
</ul>
</section>
</nav>
</header>
<div class="video">
<section class="wrapper">
<iframe width="560" height="315" src="https://www.youtube.com/embed/WeUfsRce9_M" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<h3>Video link is given if iframe is note suported by stackoverflow code snippet poster</h3>
<a href="https://www.youtube.com/embed/WeUfsRce9_M" target="_blank" >Video link</a>
</section>
</div>
</body>
</html>
infinite
并将速度设置为3s
。 - Adam Jenča