【发布时间】:2017-11-28 06:00:07
【问题描述】:
所以我在他们自己的 flex-item div 中添加了 3 个图像,它们都位于一个 flex-container div 中,图像随着我缩小浏览器窗口而缩放,但是它们都保持内联而不是包装并成为单列,关于如何使它们包装的任何想法?看起来是这样的:
div class="intro">
<section id="intro-box">
<h2>In a nutshell</h2>
<p>Santorini is one of the Cyclades islands in the Aegean Sea belonging to Greece. It boasts masses of breathtaking cliffs rising over 300m from a submerged caldera. One of the of the most sizeable volcanic eruptions in recorded history happened
in the island about 3,600 years ago – the Minoan eruption, it occurred at the height of the Minoan civilization.</p>
<p>Santorini is famous for its dramatic views, spectacular sunsets, peculiar white aubergines and the beautiful town of Thira. The island pulls in circa 1.5 million tourists annually which all flock to experience the stunning panoramas and volcanic-sand
beaches.
</p>
<div class="flex-container">
<!--Photo from: www.santorinicrystalblue.com -->
<div class="flex-item"><img class="img-fluid" src="media/sontorini-greece.jpg"></div>
<!--Photo from: www.static2.traveltek.net -->
<div class="flex-item"><img class="img-fluid" src="media/santorini-view-1.jpg"></div>
<!--Photo from: www.mylossantorini.com-->
<div class="flex-item"><img class="img-fluid" src="media/santorini-restaurant.jpg"></div>
</div>
</section>
</div>
</main>
这是 CSS:
/* Flexbox */
.intro .flex-container {
width: 100%;
display: flex;
flex-direction: row;
justify-content: center;
flex-wrap: wrap;
}
.intro .flex-item {
width: 30%;
flex-direction: column;
}
.intro .img-fluid {
width: 90%;
padding: 2rem 0rem 2rem 0rem;
}
提前致谢!
【问题讨论】:
-
你告诉弹性项目有
width: 30%。那是父级(弹性容器)的 30%。因此,即使父项是 6px 宽,每个项目也将占其中的 30%,并且它们永远不会换行。相反,使用固定宽度或媒体查询。
标签: html css flexbox responsive