我如何使我的资产净值彼此并列,因为目前我还真的不知道如何解决它。
#menu {
display: inline-block;
position: absolute;
right:0;
top: 10%;
}
<ul id="menu">
<nav>
<li><a href="Frontpage.html">Home</a></li>
<li><a href="Services.html">Services</a></li>
<li><a href="hobbies.html">My Hobbies</a></li>
<li><a href="movies.html">My favourite movies</a></li>
</nav>
</ul>
答案 0 :(得分:0)
您可以将li
类设置为float: left;
-确保仅在导航菜单中应用该类。我将类menu
更改为nav-menu
,以使其更具意义。
我还删除了list-style-type
,以便没有任何点。
ul#nav-menu {
display: inline-block;
position: absolute;
list-style-type: none;
right:0;
top: 10%;
}
ul#nav-menu li {
float: left;
margin-right: 4px;
}
<ul id="nav-menu">
<nav>
<li><a href="Frontpage.html">Home</a></li>
<li><a href="Services.html">Services</a></li>
<li><a href="hobbies.html">My Hobbies</a></li>
<li><a href="movies.html">My favourite movies</a></li>
</nav>
</ul>
答案 1 :(得分:0)
你想这样吗?
body {
padding:0;
margin:0;
}
#menu {
display:flex;
justify-content:flex-end;
position:absolute;
top:0;
right:0;
}
#menu a {
color:#000;
text-decoration:none;
padding:0 20px;
height:40px;
line-height:40px;
font-family:sans-serif;
}
#menu a:hover {
background:lightgray;
}
<div id="menu">
<a href="Frontpage.html">Home</a>
<a href="Services.html">Services</a>
<a href="hobbies.html">My Hobbies</a>
<a href="movies.html">My favourite movies</a>
</div>