【发布时间】:2022-02-06 14:21:21
【问题描述】:
我的ul 元素没有出现在标题的顶部。我尝试使用绝对位置和相对位置,但它搞砸了。 ul 应该在后台运行。是因为logo吗?我只想要一个基本的导航栏。请任何可以提供帮助的人?
@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@800&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Fruktur&family=Nunito:wght@800&display=swap");
* {
margin: 0;
padding: 0;
color: white;
list-style: none;
text-decoration: none;
box-sizing: border-box;
font-family: "Nunito", sans-serif;
}
header {
width: 100%;
height: 60px;
background-color: #141517;
.Logo {
width: 120px;
margin-top: 15px;
margin-left: 8px;
}
ul {
text-align: center;
}
li {
font-size: 15px;
margin: 0 10px;
line-height: 60px;
display: inline-block;
}
}
CSS 示例
@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@800&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Fruktur&family=Nunito:wght@800&display=swap");
* {
margin: 0;
padding: 0;
color: white;
list-style: none;
text-decoration: none;
box-sizing: border-box;
font-family: "Nunito", sans-serif;
}
header {
width: 100%;
height: 60px;
background-color: #141517;
}
header .Logo {
width: 120px;
margin-top: 15px;
margin-left: 8px;
}
header ul {
text-align: center;
}
header li {
font-size: 15px;
margin: 0 10px;
line-height: 60px;
display: inline-block;
}
<script src="https://kit.fontawesome.com/7ddb0129cc.js" crossorigin="anonymous"></script>
<body style="background-color: #202020">
<header>
<img class="Logo" src="Logo.svg" />
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Developing</a></li>
<li><a href="#">LeaderBoards</a></li>
</ul>
</header>
【问题讨论】:
-
您能否分享一个视觉示例,结果应该是什么样子?
-
另外,请创建一个minimal reproducible example:使用代码 sn-p 在您的问题中创建一个最小示例。
-
我已经给你做了一个sn-p。请改为编辑它