【发布时间】:2018-04-09 06:13:26
【问题描述】:
我有多篇文章,每篇文章都有一张图片,我正在使用 Flexbox 来设置页面样式,我想做的是每隔一行在文章和图片之间切换,所以第一行应该是像 (article-image) 然后 (image-article) 然后再 (article-image) 等等 .. 这是第一篇带有样式的文章代码,如果我做错了什么或者你有更好的建议,请告诉我.
div {
border: 1px dotted red;
display: block;
}
.article {
display: -webkit-flex;
display: flex;
flex-direction: row;
-webkit-flex-direction: row;
width: 100%;
overflow: hidden;
padding: 10px;
}
.article-content {
height: 100%;
width: 48.6666666%;
text-align: left;
}
.img-control {
margin-left: 3.5%;
width: 48%;
overflow: hidden;
align-self: stretch;
}
.img-control .image {
height: 100%;
width: 100%;
background-size: cover;
background-position: center center;
}
<div class="article">
<div class="article-content">
<h3>What is Lorem Ipsum?</h3>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
<div class="img-control">
<div class="image" style="background-image: url(//via.placeholder.com/490x338);"></div>
</div>
</div>
【问题讨论】:
标签: html image css responsive-design flexbox