嗨,我无法让我的垂直子菜单直接在父水平菜单下对齐。我只希望子菜单在悬停时出现。我自己可能已经把整个 CSS 复杂化了。我们将不胜感激任何帮助
这是HTML代码
<div id="nav_bar">
<ul>
<li><a href="index.php">Home</a> </li>
<li> <a href="about_us.php">About Us</a> </li>
<li> <a href="training.php">Training</a>
<ul>
<li> <a href="funded_training.php">Funded Training</a></li>
<li> <a href="traineeships.php">Traineeships</a></li>
<li> <a href="fee_for_service.php">Fee for Service</a></li>
<li> <a href="skill_sets.php">Enterprise Specific Skill Sets</a></li>
<li> <a href="rpl.php">RPL Assessment</a></li>
<li> <a href="international_training.php">International Training</a></li>
</ul>
</li>
<li>
<a href="employment.php">Employers</a>
<ul>
<li> <a href="existing_workers.php">Existing Workers</a></li>
<li> <a href="new_workers.php">New Workers</a></li>
</ul>
</li>
<li><a href="contact.php">Contact Us</a> </li>
<li><a href="links.php">Links</a></li>
</ul>
</div>
这是CSS
#nav_bar {
font-family: Verdana, Helvetica, Arial, sans-serif, serif;
font-size:1.2em;
font-weight:bold;
float: left;
height: 28px;
width: 689px;
margin-top: 40px;
margin-right: 20px;
margin-bottom: 0px;
margin-left: 10px;}
#nav_bar ul {
list-style-type:none;
margin:0px;
padding:0px;
overflow:hidden;}
#nav_bar li a:link, #nav_bar li a:visited {
float:left;
color: #000;
text-decoration: none;
display:block;
width: 106px;
text-align:center;
padding: 4px;
}
#nav_bar li a:hover, #nav_bar li a:active {
color: #FFF;
background-color: #184B8D;
}
#nav_bar li ul {
display: none;
position:absolute;
}
#nav_bar li ul a:link, #nav_bar li ul a:visited {
color:#000;
text-decoration:none;
display:inline-block;
width:auto;
text-align:center;
padding:4px;
}
#nav_bar li ul a:hover, #nav_bar li ul a:active {
display:block;
position: absolute;
}
#nav_bar li:hover ul {
display:block;
clear:both;
}