Flexbox / Float - 2 1 2布局 [英] Flexbox/Float - 2 1 2 Layout

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

问题描述

我尝试使用Flexbox或浮动广告创建一个2 1 2布局,如添加到此问题的图片中所示。有没有办法只使用一个有序的项目列表成功地完成这项工作?

I'm trying to create a 2 1 2 layout using Flexbox or floats as seen in the image added to this question. Is there any way to do this successfully using just an ordered list of items?

<ul>
  <li>1</li>
  <li>2</li>
  <li>3</li>
  <li>4</li>
  <li>5</li>
</ul>

1,2,4,5的大小相同,3是与其他块相同的宽度。

1,2,4,5 are the same in size and 3 is the same width as the other blocks.

我想完成这使用Flexbox,但我不能看起来2下1和5下4。

I'm trying to accomplish this using Flexbox but I can't seem the get 2 under 1 and 5 under 4.

推荐答案

code> flex-direction:column 和 flex-wrap:wrap 但我认为你必须设置 / strong>

You could do this with flex-direction: column and flex-wrap: wrap but i think you must set fixed height on parent

body, html, ul {
  margin: 0;
  padding: 0;
}
* {
  box-sizing: border-box;
}
ul {
  display: flex;
  height: 100vh; 
  list-style-type: none;
  flex-direction: column;
  flex-wrap: wrap;
}
li {
  flex: 0 0 50%;
  border: 1px solid black;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 50px;
}
li:nth-child(3) {
  flex: 0 0 100%;
}

<ul>
  <li>1</li>
  <li>2</li>
  <li>3</li>
  <li>4</li>
  <li>5</li>
</ul>

这篇关于Flexbox / Float - 2 1 2布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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