【发布时间】:2018-03-03 03:20:40
【问题描述】:
我试图让这个下拉菜单出现在一个固定的顶部栏中。
我浏览了很多教程和论坛,但没有任何帮助。
我不能:
- 当我将光标从“Trabalhos”按钮移开时,使下拉菜单保持静止。
- 当子菜单显示时,使顶部栏元素静止 - “Contato”按钮离开栏,就好像它是浮动的一样。
Here is the code in CSSDesk(请隐藏 html/css 侧边栏,以便您看到主要问题:当光标经过“Trabalhos”按钮时,许多开/关悬停闪烁)。
我才刚开始,如果我的代码乱七八糟,我很抱歉(如果确实如此,请告诉我!)
#fixtop {
width: 100%;
height: 50px;
background-color: rgba(0, 0, 0, 0.3);
float: left;
position: relative;
}
#fixtop>ul {
margin: 10px auto;
color: white;
font-size: 1.5em;
display: table;
list-style: none;
}
#fixtop>ul>li {
padding: 0 90px 0 90px;
cursor: default;
transition: 0.2s;
float: left;
}
#fixtop>ul>li>a:hover {
color: yellow;
transition: 0.2s;
}
#topbuttons #bottrab:hover~#submenu {
display: table;
}
/*SUBMENU AREA*/
#submenu {
position: relative;
display: none;
}
#submenu>a {
padding: 10px;
position: relative;
top: 50px;
width: 300px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
font-size: 0.8em;
text-align: center;
color: white;
background: rgba(0, 0, 0, 0.5);
display: block;
z-index: 3;
border-radius: 2px;
}
#submenu>nav>a:hover {
background: rgba(0, 0, 0, 0.7);
transition: 0.2s;
}
<header id="fixtop">
<ul id="topbuttons">
<li><a href="#">Sobre mim</a></li>
<li><a href="#" id="bottrab">Trabalhos</a>
<div id="submenu">
<a href="#">Manipulação de imagem</a>
<a href="#">Diagramação</a>
<a href="#">Programação Web</a>
<a href="#">Design de logo</a>
</div>
</li>
<li><a href="#">Contato</a></li>
</ul>
</header>
【问题讨论】:
标签: html css drop-down-menu hover