html - 使用 Flex 尝试根据图像获取框

标签 html css flexbox

我正在使用 flex 属性。我想要 1. 左边的框和 2.&3.向右。 enter image description here

.flex{
display:flex;
flex-wrap:wrap;
width:400px;
}
.flex > div{
flex: 0 0 50%;
}
.flex .one{
order:1;
background: red;
}
.flex .two{
order:2;
background: green;
}
.flex .three{
order:3;
background: blue;
flex:0 0 50%;
}
<div class="flex">
	<div class="one">1</div>
    <div class="three">3</div>
    <div class="two">2</div>
</div>

我试过了,但无法按照所附图片获取。

最佳答案

使用justify-content: flex-end(将flex元素沿flex轴对齐,flex行是水平的) -direction) - 请参见下面的演示:

.flex {
  display: flex;
  flex-wrap: wrap;
  width: 400px;
  justify-content: flex-end; /* added */
}

.flex>div {
  flex: 0 0 50%;
}

.flex .one {
  order: 1;
  background: red;
}

.flex .two {
  order: 2;
  background: green;
}

.flex .three {
  order: 3;
  background: blue;
  flex: 0 0 50%;
}
<div class="flex">
  <div class="one">1</div>
  <div class="three">3</div>
  <div class="two">2</div>
</div>

关于html - 使用 Flex 尝试根据图像获取框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55849780/

相关文章:

html - 固定背景与顶部导航栏和滚动

javascript - 使用 jQuery 更改路径上的 SVG 描边

html - Bootstrap 部分不会出现在移动浏览器中,但会出现在桌面版本中

javascript - 防止方向改变

html - 当 child 伸出 window 时,我的 flexbox 下方出现大空间

javascript - 如何在 flex 容器中调整固定大小( Canvas )的元素?

JavaScript 样式类型

javascript - 如何加载 CSV 文件以在 HTML5 页面上显示并使用搜索框对其进行过滤?

html - 如何让textarea占用100%的剩余空间?

html - 如何分别针对每条线将多个跨度集中在多条线上?