我正在尝试将下拉垂直菜单项打开到左侧,现在它在右侧打开,但我希望它应该在左侧打开,
我怎么能做到这一点?,我写了以下事情来完成这项工作
CSS:
#navContainer
{
margin: 0;
padding: 0;
background: red;
border: 1px solid #7398ba;
text-align: center;
width: 220px;
}
#navContainer ul
{
margin: 0;
padding: 0;
list-style: none;
}
#navContainer ul li
{
position: relative;
}
#navContainer ul li span
{
display: block;
}
#navContainer ul li a
{
text-decoration: none;
color: white;
display: block;
padding: 8px;
}
#navContainer ul li span:hover
{
/*background: pink;*/
}
#navContainer ul li a:hover
{
background: black;
}
#navContainer ul ul
{
position: absolute;
display: none;
}
#navContainer ul ul li a
{
background: #bec8cb;
}
#navContainer ul li:hover ul
{
width: 80%;
position: absolute;
display: block;
left: 218px;
top: 0;
}
HTML :-
<div id="navContainer">
<ul>
<li><span><a href="#">Home</a></span></li>
<li>
<span><a href="#">About </a></span>
<ul>
<li><a href="#">Our business</a></li>
<li><a href="#">Our History </a></li>
</ul>
</li>
<li>
<span><a href="#">Services</a></span>
<ul>
<li><a href="#">Web Design</a></li>
<li><a href="#">Web templates </a></li>
<li><a href="#">Tutorials </a></li>
</ul>
</li>
<li><span><a href="#">Contact</a></span></li>
<li><span><a href="#">News</a></span></li>
</ul>
</div>
当前结果:-
我想要的结果