css - flexbox布局问题?

查看:82
本文介绍了css - flexbox布局问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

基本代码如下:

<section>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</section>

//css
section {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  border:1px solid #000;
  height: 500px;  // 问题出在这句???
}
div {
  display: inline-flex;
  background-color: #777;
  width: 49%;
  height: 50px;
  margin: 5px 0;
}

然而我想要这样的布局:

如何做到既给父元素加高度值,又能让它如上图合理排序??谢谢,代码点击这里

解决方案

section {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  border:1px solid #000;
  height: 500px;
  align-content: flex-start  //new
}

这篇关于css - flexbox布局问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆