我无法将菜单水平放置任何我想做的事情。我做错了什么? 我想问题来自内联选项,但我不确定。 如果有人能纠正我的代码,我会非常感激。谢谢。
HTML代码
<nav>
<ul>
<li class = "current-item"> <a href = "index.php"> Home </a> </li>
<li> <a href = "profile.php"> Profile </a> </li>
<li> <a href = "contact.php"> Contact </a> </li>
</ul>
</nav>
CSS代码
nav{
position:absolute;
margin-top: 288px;
margin-left: 0px;
width: 25px;
height:25px;
z-index: 2;
}
nav > ul > li {
font-size:20px;
color:white;
padding:10px 40px;
display:inline-block;
text-shadow:0px 1px 0px rgba(0,0,0,0.4);
z-index: 2;
}
nav > ul > li> a {
text-decoration:none;
color:#000000;
transition:all linear 0.15s;
}
nav > ul >.current-item > a{
background-color:rgba(0,0,0,0.35);
text-align: center;
color: white;
padding: 3px 22px;
border-radius:10px;
border:none;
cursor: pointer;
width: 50px;
height: 28px;
z-index:2;
text-decoration:none;
}
nav> ul > li:hover> a{
background-color:rgba(0,0,0,0.35);
text-align: center;
color: white;
padding: 3px 22px;
border-radius:10px;
border:none;
cursor: pointer;
width: 50px;
height: 28px;
z-index:2;
}
答案 0 :(得分:1)
从导航中删除宽度。
nav{
position:absolute;
margin-top: 288px;
margin-left: 0px;
height:25px;
z-index: 2;
}