【发布时间】:2019-03-15 13:03:39
【问题描述】:
我这里有一个密码笔 - https://codepen.io/anon/pen/ePWJGE
是否可以有一个最大宽度的元素而让其他元素占用剩余空间。
在我的代码笔中的第二个容器中,我希望灰色条的最大宽度为 300 像素,其余元素在剩余空间中均匀分布。
.container{
border: 1px solid lightgrey;
max-width: 900px;
}
.row{
display: flex;
justify-content: space-between;
//flex-wrap:wrap;
}
.row-item{
padding: 10px 5px;
border-left: 1px solid grey;
}
.row:nth-child(even){
background: lightgrey;
}
.mobile-nav{
display: none;
}
.row-item-bar{
flex-grow: 1;
}
.bar{
background: lightgrey;
height: 20px;
max-width: 300px;
}
@media(max-width: 500px){
.row{
display: block;
}
.sc-left{
float: left;
}
.sc-right{
float: right;
}
.row-item{
border-bottom: 1px solid grey;
}
.mobile-nav{
display: inline-block;
}
}
【问题讨论】: