【发布时间】:2016-07-13 08:18:04
【问题描述】:
我在使用 flexbox 布局时遇到了一些问题。我想要实现的是下面的图像是如何定位的。但是,使用边距和填充,我可以将元素移动到正确的位置,而不会发生剧烈变化。
我可能不正确地处理这个问题。如果有人能给我一些建议和解释如何正确地做到这一点,那就太好了。
线框
现在的情况
HTML
<div style="background: grey;">
<div class="parent-container" style="flex-direction: column; align-items: center; margin: 10px;">
<div class="aelia-text child33">
The first of it's kind, to<br/>
create a better customer<br/>
journey with reduced<br/>
collection waiting time and<br/>
a special moment that makes<br/>
even the most jet-lagged<br/>
shopper smile.
</div>
<div class="child33">
<div class="img-wrapper" ng-style="{'background-image':'url(/assets/Aelia_Robot_highres006.jpg)'}"></div>
</div>
<div class="child33">
<div class="img-wrapper" ng-style="{'background-image':'url(/assets/AELIA_IMAGE.jpg)'}"></div>
</div>
</div>
</div>
CSS
.aelia-text {
background: white;
color: black;
font-size: 1.5vw;
font-family: portland-medium-font;
-ms-flex-pack: center;
justify-content: center;
-ms-flex-align: center;
align-items: center;
display: -ms-flexbox;
display: flex;
}
.child33 {
position: relative;
-ms-flex-positive: 1;
flex-grow: 1;
height: 50%;
width: 33.3%;
max-width: calc(100% * (1/3));
margin: 0;
position: relative;
-ms-flex-flow: nowrap row;
-o-flex-flow: nowrap row;
flex-flow: nowrap row;
border: 0;
outline: 0;
}
.parent-container {
display: -ms-flexbox;
display: flex;
font-size: 0;
margin: 0;
padding: 0;
border: 0;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
height: 92vh;
width: 100vw;
}
.img-wrapper {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-size: cover;
}
【问题讨论】: