gpt4 book ai didi

html - 请帮我解决这个导航栏

转载 作者:行者123 更新时间:2023-11-28 01:54:13 25 4
gpt4 key购买 nike

这是我创建的垂直导航栏的代码,我还需要在此处添加一件事,那就是鼠标悬停时弹出菜单。我尝试了很多东西,但没有用。这是我的 CSS 代码

.navbar{
list-style-type: none;
margin: 0;
padding: 10px;
width: 280px; /* width of menu */
}

.navbar li{
border-bottom: 1px solid white; /* white border beneath each menu item */
}

.navbar li a{
background: #333 url(media/sexypanelright.gif) no-repeat right top; /*color of menu by default*/
font: bold 13px "Lucida Grande", "Trebuchet MS", Verdana;
display: block;
color: white;
width: auto;
padding: 5px 0; /* Vertical (top/bottom) padding for each menu link */
text-indent: 8px;
text-decoration: none;
border-bottom: 1px solid black; /*bottom border of menu link. Should be equal or darker to link's bgcolor*/
}

.navbar li a:visited, .navbar li a:active{
color: white;
}

.navbar li a:hover{
background-color: black; /*color of menu onMouseover*/
color: white;
border-bottom: 1px solid black; /*bottom border of menu link during hover. Should be equal or darker to link's hover's bgcolor*/
}

html部分是这个

<ul class="navbar">
<li><a href="#">» Computers</a>

</li>
<li><a href="#" >» Networking Solutions</a></li>
<li><a href="#/">» Security Solutions</a></li>
<li><a href="#">» Office Automations</a></li>
<li><a href="#">» Gadgets</a></li>
<li><a href="#">» Projectors and Display Screens</a></li>
<li><a href="#">» Peripherals and Components</a></li>
<li><a href="#">» Softwares</a></li>
<li class="lastitem"><a href="#">» Customized Solutions</a></li>
</ul>

我想要的是,当用户将鼠标悬停在此列表中的任何元素上时,会出现一个带有菜单的弹出菜单。提前谢谢你。

最佳答案

这是您要找的吗?

JSFiddle

这是关键,当你将鼠标悬停在 li 上时,带有 .flyout 类的 child 将可见

.navbar li:hover .flyout {
display: block;
}

PS:我只在主菜单中为前两个语音添加了一个子菜单,以保持代码简短

关于html - 请帮我解决这个导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17973435/

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