使用显示器时,保证金右翼汽车无法正常工作:flex
我正在尝试制作一个Navbar UISNG Flexbox,但透视权:自动;或左键:自动;不起作用,BEL0W是HTML和CSS代码 HTML
<div class="nav">
<ul class="navbar">
<li>
<h1 id="logo">SocialNetwork</h1>
</li>
<li>
<form class="search">
<input type="text" >
<input type="submit" value="search">
</form>
</li>
<li><img class="profile-photo" </li>
<li><a id="username" href="{% %}">
<h3 id="user">username</h3>
</a></li>
</ul>
</div>
CSS
*{
box-sizing: border-box;
margin:0;
padding:0;
}
.navbar{
display: flex;
align-items: center;
width:100%;
}
.profile-photo{
margin-right: auto;
}
I am trying to make a navbar uisng flexbox but margin-right:auto; or margin-left:auto; is not working,bel0w are the html and css code
Html
<div class="nav">
<ul class="navbar">
<li>
<h1 id="logo">SocialNetwork</h1>
</li>
<li>
<form class="search">
<input type="text" >
<input type="submit" value="search">
</form>
</li>
<li><img class="profile-photo" </li>
<li><a id="username" href="{% %}">
<h3 id="user">username</h3>
</a></li>
</ul>
</div>
css
*{
box-sizing: border-box;
margin:0;
padding:0;
}
.navbar{
display: flex;
align-items: center;
width:100%;
}
.profile-photo{
margin-right: auto;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过给父flex容器A
josify-content:space-bettem;
属性这样的水平分散项目:You can spread out items horizontally by giving the parent flex container a
justify-content: space-between;
attribute like this: