gpt4 book ai didi

html - 下拉菜单向左浮动

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

我制作了一个菜单,我希望下拉菜单位于“Fruitsoorten”选项卡下方的中央。但是现在所有三个元素都彼此相邻。有谁知道如何解决这一问题?提前致谢。

nav {
float: right;
border-radius: 15px;
margin-right: 15%;
}
nav ul {
list-style-type: none;
margin-top: 55px;
background-color: black;
}
nav li {
display: inline-block;
position: relative;
padding: 10px;
}
nav li ul {
display: none;
}
nav li li {
display:
}
nav li:hover ul {
display: block;
}
nav a {
text-decoration: none;
color: white;
font-size: 20px;
}
nav li:hover {
background-color: gray;
}
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li>
<a href="geschiedenis.html">Fruitsoorten</a>
<ul>
<li><a href="team.html">Kersen</a></li>
<li><a href="team.html">Appels</a></li>
<li><a href="team.html">Pruimen</a></li>
</ul>
<li>
<li><a href="team.html">Team</a></li>
<li><a href="agenda.html">Agenda</a></li>
<li><a href="fotos.html">Foto's</a></li>
<li><a href="vacatures.html">Vacatures</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>

最佳答案

你也可以尝试这种风格。 http://codepen.io/nehemc/pen/LkyQvq

nav {
float: right;
border-radius: 15px;
margin-right: 15%;
}

nav ul {
list-style-type: none;
margin-top: 55px;
background-color: black;
}

nav li {
display: inline-block;
position: relative;
}

nav a {
text-decoration: none;
color: white;
font-size: 20px;
padding: 10px;
display:block;
}

nav ul ul {
display: none;
position: absolute;
z-index: 999;
left: 0;
margin-top: 0;
}

nav li:hover ul {
display: block;
}

nav li:hover {
background-color: gray;
}

关于html - 下拉菜单向左浮动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38141864/

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