我正在为我的兄弟会(Phi Delta Theta)建立一个网站,我想为我的一个链接创建一个下拉列表,但无法弄清楚。
<!-- Nav -->
<nav id="menu">
<ul class="links">
<li><a href="Home.html">Home</a></li>
<li><a href="Our Mission.html">Our Mission</a></li>
<li><a href="Join PDT.html">Join PDT</li>
<div class="dropdown-container">
<ul>
<li>Future Phi Delt <a href="http://futurephidelt.org/"> </li>
<li>Parent's Guide <a href="http://www.phideltatheta.org/join/parents-guide/"> </li>
</ul>
</div>
<li><a href="elements.html">Elements</a></li>
</ul>
</nav>
答案 0 :(得分:0)
您需要使用CSS和HTML
这是https://www.w3schools.com/css/css_dropdowns.asp的摘录
<style>
.dropdown {
position: relative;
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);
padding: 12px 16px;
z-index: 1;
}
.dropdown:hover .dropdown-content {
display: block;
}
</style>
<div class="dropdown">
<span>Mouse over me</span>
<div class="dropdown-content">
<p>Hello World!</p>
</div>
</div>
答案 1 :(得分:0)
您可能可以执行以下代码片段:将鼠标悬停在“加入PDT”链接上以查看选项,还可以从中选择其他各种选项,好的资源是W3Schools:Dropdown examples。我有使用了w3schools为您准备的代码段供您在下面查看,希望它可以帮助您入门。
<html>
<style>
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #ddd;}
.dropdown:hover .dropdown-content {display: block;}
</style>
<body>
<!-- Nav -->
<nav id="menu">
<ul class="links">
<li><a href="Home.html">Home</a></li>
<li><a href="Our Mission.html">Our Mission</a></li>
<div class="dropdown"><a href="Join PDT.html">Join PDT <b class="caret"></b></a>
<div class="dropdown-content">
<a href="http://futurephidelt.org/"> Future Phi Delt </a>
<a href="http://www.phideltatheta.org/join/parents-guide/">Parent's Guide</a>
</div>
</div>
<li><a href="elements.html">Elements</a></li>
</ul>
</nav>
</body>
</html>