我试图实现这种布局。细线必须在其中包含所有三个部分。页眉和页脚需要垂直居中。并且内容应该占据高度,直到页脚到达视口的底部。请注意,细线仅用于显示边界......它们实际上不应该在代码中。
到目前为止工作:
.wrapper{
display: flex;
flex-direction: column;
height: 100vh;
background-color: pink;
}
header, footer, .content{
border: 1px solid black;
}
header, footer {
flex: 0 0 92px;
}
.content{
flex: 1;
}

<div class="wrapper">
<header>Header</header>
<div class="content">Content</div>
<footer>Footer</footer>
</div>
&#13;
答案 0 :(得分:1)
您可以使用align-items
属性在页眉和页脚内部进行垂直对齐
.wrapper{
display: flex;
flex-direction: column;
height: 100vh;
margin-left: 10%;
margin-right: 10%;
background-color: pink;
}
header, footer, .content{
border: 1px solid black;
}
header, footer {
flex: 0 0 92px;
display: flex;
align-items: center;
}
.content{
flex: 1;
}
&#13;
<div class="wrapper">
<header>Header</header>
<div class="content">Content</div>
<footer>Footer</footer>
</div>
&#13;
答案 1 :(得分:1)
为标题,内容和页脚提供边距和/或宽度,并将它们与父级的中心对齐
.wrapper{
display: flex;
flex-direction: column;
height: 100vh;
background-color: pink;
align-items: center;
}
header, footer, .content{
margin: auto;
border-bottom: 1px solid black;
width:100%;
}
header .section,footer .section, .content .section{
height:100%;
width:80%;
margin:auto;
background-color:red
}
header, footer {
flex: 0 0 92px;
}
.content{
flex: 1;
}
<div class="wrapper">
<header><div class="section">Header</div></header>
<div class="content"><div class="section">Content</div></div>
<footer><div class="section">Footer</div></footer>
</div>