Flexbox 中心和右下角的项目 [英] Flexbox center and bottom right item

查看:26
本文介绍了Flexbox 中心和右下角的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 flexbox 实现以下结果:

我尝试了以下 html,但我无法让它工作.

<div class="flex-item-center"><p>框 A 中的一些文本</p>

<div class="flex-item-bottom"><p>框 B 中的一些文本....</p>

CSS:

.flex-center {显示:弹性;对齐项目:居中;对齐内容:居中;对齐内容:居中;}.flex-item-center {对齐自我:居中;}.flex-item-bottom {align-self: flex-end;}

如何使它看起来像图像?

解决方案

我已经提出了一个可行的解决方案.

.flex-center {背景色:#739FD0;颜色:#000000;显示:弹性;弹性方向:行;flex-wrap: 包裹;对齐内容:居中;对齐内容:居中;对齐项目:居中;高度:400px;}.flex-center-bottom {背景色:#739FD0;颜色:#000000;显示:弹性;弹性方向:行;flex-wrap: 包裹;justify-content: flex-end;对齐内容:居中;对齐项目:居中;}.flex-item-center {边框:实心 2px #4675AA;订单:0;弹性:0 1 自动;对齐自我:居中;}.flex-item-bottom {边框:实心 2px #4675AA;订单:1;弹性:0 1 自动;align-self: flex-end;}

<div class="flex-item-center"><p>在此处删除文件</p>

<div class="flex-center-bottom"><div class="flex-item-center"><p>提示:您还可以在所有文件页面中删除文件</p>

2017 年更新:在 Google Chrome 版本 62.0.3202.89(官方版本)(32 位)中测试.

.flex-center,.flex-center-bottom {对齐项目:居中;背景色:#739FD0;颜色:#000000;显示:弹性;}.flex-center {高度:400px;对齐内容:居中;}.flex-center-bottom {justify-content: flex-end;}.flex-item-center {边框:实心 2px #4675AA;字体系列:Arial、sans-serif;字体大小:1.6em;行高:1px;填充:0 3px;}

<div class="flex-item-center"><p>A 框中的一些文本</p>

<div class="flex-center-bottom"><div class="flex-item-center"><p>框 B 中的一些文本...</p>

希望对你有帮助.

I'm trying to achieve the following result using flexbox:

I tried the with the following html but I can't get it to work.

<div class=" flex-center">
    <div class="flex-item-center">
        <p>
            Some text in box A
        </p>
    </div>
    <div class="flex-item-bottom">
        <p>Some text in box B....</p>
    </div>
</div>

CSS:

.flex-center {
  display: flex;
  align-items: center;
  align-content: center;
  justify-content: center;
}
.flex-item-center {
  align-self: center;
}

.flex-item-bottom {
  align-self: flex-end;
}

How can I make it look like the image?

解决方案

I've made a posible solution.

.flex-center {
  background-color: #739FD0;
  color: #000000;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  align-items: center;
  height: 400px;
}
.flex-center-bottom {
  background-color: #739FD0;
  color: #000000;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-content: center;
  align-items: center;
}
.flex-item-center {
  border: solid 2px #4675AA;
  order: 0;
  flex: 0 1 auto;
  align-self: center;
}
.flex-item-bottom {
  border: solid 2px #4675AA;
  order: 1;
  flex: 0 1 auto;
  align-self: flex-end;
}

<div class="flex-center">
  <div class="flex-item-center">
    <p>DROP FILES HERE</p>
  </div>
</div>
<div class="flex-center-bottom">
  <div class="flex-item-center">
    <p>Hint: You can also drop files in the all files page</p>
  </div>
</div>

Update 2017: Tested in Google Chrome Versión 62.0.3202.89 (Build oficial) (32 bits).

.flex-center,
.flex-center-bottom {
  align-items: center;
  background-color: #739FD0;
  color: #000000;
  display: flex;
}

.flex-center {
  height: 400px;
  justify-content: center;
}

.flex-center-bottom {
  justify-content: flex-end;
}

.flex-item-center {
  border: solid 2px #4675AA;
  font-family: Arial, sans-serif;
  font-size: 1.6em;
  line-height: 1px;
  padding: 0 3px;
}

<div class="flex-center">
  <div class="flex-item-center">
    <p>Some text in box A</p>
  </div>
</div>
<div class="flex-center-bottom">
  <div class="flex-item-center">
    <p>Some text in box B...</p>
  </div>
</div>

I hope this helps you.

这篇关于Flexbox 中心和右下角的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆