这是我的代码的样子。我当时使用flexbox填充导航中的所有水平空间,但是当我将鼠标悬停时,似乎错过了迫使他们填充整个空间的小缝隙。
parent{
overflow: auto;
white-space: nowrap;
}
ul{
display: flex;
justify-content: space-between;
width: 100%;
}
li{
flex: 0 1 auto;
}
Demo 你可以在这里看看
答案 0 :(得分:0)
#menu a {
color: #009fda;
text-decoration: none;
}
.wrapper {
width: 100%;
padding: 0;
margin: 0;
}
.inner-wrapper {
max-width: 1050px;
margin: 0 auto;
padding: 0;
}
#Nav {
margin: 0 auto !important;
padding: 0 !important;
background: #01a182;
box-shadow: 0 0 3px #999;
width: 100% !important;
}
#Nav .inner-wrapper {
overflow: auto;
white-space: nowrap;
}
#Nav #menu {
padding-top: 0 !important;
padding-bottom: 0 !important;
overflow: hidden;
white-space: nowrap;
position: relative;
padding: 0 !important;
margin: 0;
width: 100% !important;
display: table;
}
#menu li {
display: table-cell;
list-style: none;
margin: 0;
padding: 0;
border-right: 1px solid rgba(255, 255, 255, .4);
}
#menu a.Link {
color: #fff;
padding: 8px 4px;
text-align: center;
font-size: 1.2rem;
font-weight: 400;
display: block;
}
#menu li:nth-of-type(1) {
border-left: 1px solid rgba(255, 255, 255, .4);
}
#menu a.Link.active,
#menu a.Link:hover {
background: #0e6857;
color: #fff;
}
<div class="wrapper" id="Nav">
<div class="inner-wrapper">
<ul id="menu">
<li> <a class="Link" href="#">Home</a></li>
<li> <a class="Link" href="#">1</a></li>
<li> <a class="Link" href="#">2</a></li>
<li> <a class="Link" href="#">3</a></li>
<li> <a class="Link" href="#">4</a></li>
<li> <a class="Link" href="#">5</a></li>
</ul>
</div>
</div>