gpt4 book ai didi

html - 悬停下拉菜单不显示

转载 作者:太空宇宙 更新时间:2023-11-04 10:07:44 25 4
gpt4 key购买 nike

我正在尝试创建一个可悬停的下拉菜单,其工作方式类似于 this .

但是,我网站的下拉菜单好像没有出现。

检查代码后(使用 Chrome 中的开发人员工具),我发现我的下拉菜单被我的#content div 覆盖了。

我应该怎么做才能将下拉菜单置于顶部?

body {
margin: 0;
font-family: "Comic Sans MS", cursive, sans-serif;
background-color: #000000;
background-size: cover;
background-attachment: fixed;
color: #ffffff;
background-image: url("../background/home.jpg")
}

@keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}

#home {
float: left;
font-size: 1.5em;
}

ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: rgba(236, 130, 53, 0.75);
position: fixed;
top: 0;
width: 100%;
}

li {
float: right;
}

li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

a {
transition: all 0.5s;
}

#content {
margin-top: 61px;
animation: fadein 5s;
}

.menu a {
color: #0000ff;
font-size: 1.5em;
font-weight: bold;
}

.menu a:hover {
background-color: #ff0000;
color: #ffffff;
}

.menu {
display: inline-block
}

.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}

.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}

.dropdown-content a:hover {
background-color: #f1f1f1
}

.menu:hover .dropdown-content {
display: block;
}
<body>
<div id="navigation-menu">
<ul>
<li class="menu">
<a href="#">Transport</a>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</li>
</ul>
</div>
<div id="content">
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
</div>
</body>

最佳答案

删除 overflow: hidden;来自 <ul>

ul {
list-style-type: none;
margin: 0;
padding: 0;
background-color: rgba(236, 130, 53, 0.75);
position: fixed;
top: 0;
width: 100%;
}

这会阻止内容流出 div 以提供您正在寻找的效果。

关于html - 悬停下拉菜单不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37854167/

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