我有3个flex项:标题,内容和页脚。我想要一切都要弯曲但是标题恰好是250px ...我添加了一个样式.height-250 {max-height: 250px;}
但是它没有用。
/* GRID */
.grid {
display: flex;
}
.col {
background-color: rgba(100, 255, 255, 0.1);
border: 1px solid rgb(100, 255, 225);
padding: 5px;
}
.col-1-12 {
flex-basis: 8.3333%;
}
.col-2-12 {
flex-basis: 16.6666%;
}
.flex-column {
flex-direction: column;
}
.full-width {
flex-grow: 100;
}
.wrapper,
html,
body {
height: 100%;
margin: 0;
}
.wrapper {
display: flex;
flex-direction: column;
}
.height-250 {
max-height: 250px;
}
<div class="wrapper grid flex-column">
<div class="col col-1-12 height-250">Header</div>
<div class="grid col full-width col-2-12">Content</div>
<div class="col col-1-12">Footer</div>
</div>
答案 0 :(得分:2)
您应该使用max-height: 250px
而不是flex: 0 0 250px
而不是flex-direction: column
,而是将元素的高度设置为250px。
.grid {
display: flex;
}
.col {
background-color: rgba(100, 255, 255, 0.1);
border: 1px solid rgb(100, 255, 225);
padding: 5px;
}
.col-1-12 {
flex-basis: 8.3333%;
}
.col-2-12 {
flex-basis: 16.6666%;
}
.flex-column {
flex-direction: column;
}
.full-width {
flex-grow: 100;
}
.wrapper,
html,
body {
height: 100%;
margin: 0;
}
.wrapper {
display: flex;
flex-direction: column;
}
.height-250 {
flex: 0 0 250px;
}
<div class="wrapper grid flex-column">
<div class="col col-1-12 height-250">Header</div>
<div class="grid col full-width col-2-12">Content</div>
<div class="col col-1-12">Footer</div>
</div