我有以下代码
header {
width: 100%;
height: 65px;
background: #fff;
font-size: 11px;
font-weight: bold;
text-transform: uppercase;
display: flex;
justify-content: space-between;
align-items: center;
color: #252c3a;
}
#menu {
width: 100%;
display: flex;
margin-left: 28%;
}
#menu div {
width: 100px;
height: 65px;
display: flex;
align-items: center;
justify-content: center;
position: relative;
}<header>
<div id="logo">
<img src="img/header/logo.png" alt="Logo">
</div>
<div id="menu">
<div>Home</div>
<div>Club-Life</div>
<div>Training</div>
<div>Instructors</div>
<div>Contact</div>
</div>
其他块的宽度是100%,但标题宽度比下面的块更大。我使用justify-content:空格。
发布于 2020-01-03 21:27:07
删除width和margin
在表头添加flex-wrap
header {
width: 100%;
height: 65px;
background: #fff;
font-size: 11px;
font-weight: bold;
text-transform: uppercase;
display: flex;
justify-content: space-between;
align-items: center;
color: #252c3a;
flex-wrap:wrap;
}
#menu {
display: flex;
flex-wrap:wrap;
}发布于 2020-01-03 22:03:29
我们需要做的事情很少:
header中的:
1. Remove width在#main:中
1. Remove width
2. Remove margin菜单目录#:中的目录
1. Remove everything and just add margin left演示: https://codepen.io/Bibeva/pen/povddJr
最终代码:
header {
height: 65px;
background: #fff;
font-size: 11px;
font-weight: bold;
text-transform: uppercase;
display: flex;
justify-content: space-between;
align-items: center;
color: #252c3a;
}
#menu {
display: flex;
}
#menu div {
margin: 0 0 0 30px;
}发布于 2020-01-03 21:49:32
#menu {
display: flex;
}
就这些,你能试试这个吗?
https://stackoverflow.com/questions/59579406
复制相似问题