gpt4 book ai didi

html - Flexbox 中心和右下角的元素

转载 作者:太空狗 更新时间:2023-10-29 13:50:17 24 4
gpt4 key购买 nike

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

我尝试使用以下 html,但无法正常工作。

<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;
}

如何让它看起来像图片?

最佳答案

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

.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>

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

.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>

希望对你有帮助

关于html - Flexbox 中心和右下角的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32402001/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com