【发布时间】:2018-02-24 23:54:33
【问题描述】:
我很难通过 css 将两个图像调用到它们的容器中。我已经重新创建了我在下面构建的网站的部分代码。
section 本身跨越 100% 的宽度。部分内的image containers 占100% 宽度各占50%,flex 占左右两侧。但是,当我调用图像时,什么都没有出现,而且我不确定我的代码的哪一部分阻碍了图像的显示,甚至阻碍了图像的显示。以下是我的代码:
main {
height:100%;
width: 100%;
background-color: white;
}
.section {
height: 100%;
width: 100%;
}
.for-eduBusiness {
height: 100%;
width: 100%;
min-height: 450px;
border: 1px solid;
display: flex;
justify-content: flex-start;
flex-direction: row;
flex-wrap: wrap;
}
.image-container-left {
height: 100%;
width: 50%;
border: 1px solid red;
flex: 0 0 auto;
background: #ccc
url("https://www.moooi.com/sites/default/files/styles/large/public/product-images/random_detail.jpg?itok=ErJveZTY") no-repeat center center;
background-size: cover;
}
.image-container-right {
height: 100%;
flex: 0 0 auto;
width: 50%;
border: 1px solid red;
background: #ccc url("https://www.moooi.com/sites/default/files/styles/large/public/product-images/random_detail.jpg?itok=ErJveZTY") no-repeat center center;
background-size: cover;
}
<main>
<div class="section for-eduBusiness">
<div class="image-container-left"></div>
<div class="image-container-left"></div>
</div>
</main>
【问题讨论】:
-
将此添加到您的代码中:html, body { height: 100%; }