导航栏中的下拉菜单不起作用

问题描述 投票:1回答:1

我正在尝试在导航栏的右侧获得下拉导航,但是我的下拉菜单项根本没有出现,并且当鼠标悬停在上方时,我的按钮为我提供了一条蓝线,好像是一个链接。

HTML:

 <div>
 <div class="dropdown "> 
<nav class="navbar navbar-expand-md bg-dark navbar- 
 dark py-3">
    <a id="name" href="index.html">
        <img src="images/headericon.png" width="40" height="40" class="d-inline-block align-top"   alt="">

    </a>
    <h5 style="font-size: 22px" class="ml-2 text-info mt-2">webname</h5>
</div>

   <ul> 
     <li><a href="#">User12345</a>
    <ul>
    <li><a href="#">Profile</a></li>
    <li><a href="#">Favourite</a></li>
    <li> <a href="#">Sign Out</a></li>

      </ul>
     </li>
      </ul>


     </div> 
    </nav>

CSS:

body {
font-family: arial;
margin: 0;
padding: 0;
}

.dropdown {
margin: 0 auto;

}



ul {
transform: translateY(-110%);
padding: 0;
margin: 0 auto;
float: right;
margin-right:30px;


}

 ul li {

position: relative;
list-style: none;
display: inline-block;
box-sizing: border-box;


}

ul li a {
display: block;
padding: 0 15px;
color: #D3D3D3;
text-decoration: none;
line-height: 60px;
font-size: 20px;

  }
ul li a:hover {
background: #494c4e;
}


ul ul {
position: absolute;
top: 60px;
display: none;
}
html css visual-studio
1个回答
1
投票

您的CSS缺少显示下拉菜单“打开”状态的方法。

© www.soinside.com 2019 - 2024. All rights reserved.