CSS:下拉菜单浮动在顶部
所以我用 html/css/js 制作了这个下拉菜单..它在鼠标悬停时向下滑动,但现在它向下滑动错误,我的意思是它将我的文本向下移动,这是我不希望它这样做的..我希望它像浮动一样在它上面,所以文本位于下拉菜单的后面
左边是它的样子,右边是鼠标悬停时的样子。 正如您所看到的“示例我”文本,我不希望它像那样向下移动,我希望菜单像浮动在顶部一样,这样当您再次移开鼠标时,您可以看到“示例我”
这是我的菜单 CSS:
.menu_class {
边框:1px实心#1c1c1c;
}
.the_menu {
显示:无;
宽度:150px;
边框:1px实线#1c1c1c;
}
.the_menu li {
背景颜色:#283d44;
}
.the_menu li a {
颜色:#FFFFFF;
文本装饰:无;
内边距:10px;
显示:块;
}
.the_menu li a:hover {
内边距:10px;
字体粗细:粗体;
颜色:#fffc30;
}
So i have this dropdown made in html/css/js.. it slides down on mouseover, but right now it slides down wrong, i mean it moves my text down which i dont want it to do.. i want it to like float over it so the text is behind the menu that comes down
At left its how it is, and on right side its when mouse over.
and as you can see the "example me" text i dont want it to move down like that, i want the menu to like float on top so when you move away your mouse again you can see "example me"
Here's my css for the menu:
.menu_class {
border:1px solid #1c1c1c;
}
.the_menu {
display:none;
width:150px;
border: 1px solid #1c1c1c;
}
.the_menu li {
background-color: #283d44;
}
.the_menu li a {
color:#FFFFFF;
text-decoration:none;
padding:10px;
display:block;
}
.the_menu li a:hover {
padding:10px;
font-weight:bold;
color: #fffc30;
}
<img src="images/button.png" width="126" height="23" class="menu_class">
<ul class="the_menu">
<li><a href="#">Profil</a></li>
</ul>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要将其定位在其他元素之上,您需要使用
如果您无法定位它,请给出位置:相对于包含 .the_menu 的任何元素
还要注意,z-index 可以很好地处理绝对定位的元素,如果您遇到让它出现在其他东西后面的问题。
To have it positioned on top of other elements, you need to use
If you have trouble positioning it, give position:relative to whatever element contains .the_menu
Also be aware that z-index works well with absolutely positioned elements, if you run into the problem of having it show up behind something else.
在下拉菜单中使用
position:absolute;
。Use
position: absolute;
on the dropdown.