gpt4 book ai didi

javascript - href 菜单栏上的下拉按钮

转载 作者:行者123 更新时间:2023-11-28 02:21:53 24 4
gpt4 key购买 nike

我有一个由多个链接组成的菜单栏,我想让第三个链接成为一个下拉列表。

有没有办法可以在这些 href 链接下放置一个下拉列表?我需要选项卡 3 才能有一个下拉列表,其中包含值 6 和 7。我在互联网上找不到任何其他示例。请帮忙

nav {
position: relative;
width: 100%;
height: 50px;
background-color: #34495e;
border-radius: 8px;
font-size: 0;
}

nav a {
line-height: 50px;
height: 100%;
font-size: 15px;
display: inline-block;
position: relative;
z-index: 1;
text-decoration: none;
text-transform: uppercase;
text-align: center;
color: white;
cursor: pointer;
}

nav .animation {
position: absolute;
height: 100%;
top: 0;
z-index: 0;
transition: all .5s ease 0s;
border-radius: 8px;
}

a:nth-child(1) {
width: 200px;
}

a:nth-child(2) {
width: 200px;
}

a:nth-child(3) {
width: 200px;
}

a:nth-child(4) {
width: 200px;
}

a:nth-child(5) {
width: 200px;
}

nav a:nth-child(1):hover~.animation {
width: 200px;
left: 0;
background-color: #29363B;
}

nav a:nth-child(2):hover~.animation {
width: 200px;
left: 200px;
background-color: #EA495F;
}

nav a:nth-child(3):hover~.animation {
width: 200px;
left: 400px;
background-color: #F4837D;
}

nav a:nth-child(4):hover~.animation {
width: 200px;
left: 600px;
background-color: #FAA664;
}

nav a:nth-child(5):hover~.animation {
width: 200px;
left: 800px;
background-color: #99B998;
}

.active {
border-radius: 8px;
background-color: #29363B;
color: white;
}
<nav>
<a href="#" class="active" style="text-decoration: none; color: white">ONE</a>
<a href="#" style="text-decoration: none; color: white">TWO</a>
<a href="#" style="text-decoration: none; color: white">THREE</a>
<a href="#" style="text-decoration: none; color: white">FOUR</a>
<a href="#" style="text-decoration: none; color: white">FIVE</a>
<div class="animation start-home"></div>
</nav>

最佳答案

您可以在链接内进行选择,该链接是隐藏的,直到悬停该链接。

link__dropdown {
display: none;
}

link:hover link__dropdown {
display: block;
}


<nav>
<a href="#" class="active" style="text-decoration: none; color: white">ONE</a>
<a href="#" style="text-decoration: none; color: white" class="link">TWO</a>
<a href="#" style="text-decoration: none; color: white" class="link">
<select class="link__dropdown">
<option>6</option>
<option>7</option>
</select>
</a>
<a href="#" style="text-decoration: none; color: white" class="link">FOUR</a>
<a href="#" style="text-decoration: none; color: white" class="link">FIVE</a>
<div class="animation start-home"></div>
</nav>

关于javascript - href 菜单栏上的下拉按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57071645/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com