html - 如何均匀分布
问题描述
我正在尝试为投资组合网站创建一个简单的导航栏。我的 HTML 和 CSS 在下面。我不知道如何均匀地间隔 '''li''' 项目。我无法将 justifiy-content:space-evenly 应用于 UL,因为相同的代码正在应用于 '''div class="headerContainer'''
.headerContainer {
display: flex;
background-color: lightblue;
justify-content: space-between;
align-items: center;
}
ul {
list-style-type: none;
display: flex;
}
li a {
text-decoration: none;
}
<header>
<div class="headerContainer">
<div class="logo">Robert Emmet</div>
<nav>
<ul>
<li><a href="#" class="">About</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</div>
</header>
解决方案
.headerContainer {
display: flex;
background-color: lightblue;
justify-content: space-between;
align-items: center;
}
ul {
list-style-type: none;
display: flex;
width: 100%;
justify-content: space-evenly;
}
nav {
width: 100%;
}
<header>
<div class="headerContainer">
<div class="logo">Robert Emmet</div>
<nav>
<ul>
<li><a href="#" class="">About</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</div>
</header>
推荐阅读
- node.js - laravel npm run dev 错误!代码 ELIFECYCLE 在@开发脚本处失败
- scala - scala中包的令人困惑的命名约定
- spring - 如何使用 jpa 本机查询读取 clob 数据?以及 jpa 接口和服务类应该如何?
- javascript - 如果使用增量按钮填充文本输入,则为 keyup 函数
- python - 用于在元组中保持计数的 Python 数据结构?
- c# - Application_BeginRequest 在 UserControl 上不起作用
- sql-server - 如何调整我的结果以每年对行进行排名
- android - 将数据从视图寻呼机中的片段传递到已发生的特定操作的前一个片段
- javascript - Spring MVC jsp页面中的Vue.js问题
- c# - 带有 Stringbuilder 的 C#“编码器”