我找不到为什么flex-end在我的网站上不工作,我知道有什么东西打断了它,但我就是找不到它。
对于任何有兴趣帮助的人,这里的代码,我试图只对齐navbar-links-end和navbar-links-middle到navbar的结尾:
这就是你应该知道的所有细节,如果还有什么其他的只是发表评论,我会尽快回答我可以
body {
font-family: 'Roboto', sans-serif;
}
.navbar {
top: 0;
left: 0;
display: flex;
flex-direction: row;
position: fixed;
background: white;
margin-left: auto;
border-bottom: 1px solid black;
width: 70px;
height: 70px;
}
.navbar-logo {
justify-content: flex-start;
}
.navbar-links-left {
display: flex;
justify-content: flex-start;
list-style-type: none;
align-items: center;
/* add this property */
width: auto;
}
.navbar-link {
margin-right: 2rem;
color: #0068b5;
font-size: 16px;
align-items: center;
}
.navbar-links-middle {
display: flex;
justify-content: flex-end;
list-style-type: none;
align-items: center;
/* add this property */
width: auto;
}
.navbar-links-end {
display: flex;
justify-content: flex-end;
list-style-type: none;
align-items: center;
/* add this property */
margin-left: auto;
width: auto;
}
<nav class="navbar">
<img class="navbar-logo" src="images/intel-header-logo.png">
<ol class="navbar-links-left">
<li class="navbar-link">
<p>PRODUCTS</p>
</li>
<li class="navbar-link">
<p>SUPPORT</p>
</li>
<li class="navbar-link">
<p>SOLUTIONS</p>
</li>
<li class="navbar-link">
<p>DEVELOPERS</p>
</li>
<li class="navbar-link">
<p>PARTNERS</p>
</li>
</ol>
<ol class="navbar-links-middle">
<li class="navbar-link">
<i class="far fa-user"></i>
</li>
<li class="navbar-link">
<i class="fa-solid fa-globe"></i>
</li>
<li class="navbar-link" style="white-space: nowrap;">
<p>USA (ENGLISH)</p>
</li>
</ol>
<ol class="navbar-links-end">
<li class="navbar-link">
<i class="fa-solid fa-magnifying-glass"></i>
</li>
<li class="navbar-link" style="white-space: nowrap;">
<p>Search: Intel.com</p>
</li>
</ol>
</nav>
2条答案
按热度按时间mlmc2os51#
为什么有
.navbar{width:70px}
?应该是100%
:beq87vna2#
将
.navbar
更改为width: 100%;
。删除
.navbar-links-end
上的margin-left: auto;
,并将其放在.navbar-links-middle
上。