gpt4 book ai didi

html - 地铁网格样式

转载 作者:行者123 更新时间:2023-11-28 15:26:11 25 4
gpt4 key购买 nike

我正在尝试实现类似以下页面的内容: https://undsgn.com/uncode/homepages/blog-metro/

我已经尝试过并且能够接近这个:https://jsfiddle.net/futu7t1c/

但是我怎样才能让底部的那两个 small-thumbs 向上移动呢?

顺序是大、小、小、大、小、小

<div id="blog-posts">
<div class="grid big-thumb">
Title
</div>
<div class="grid small-thumb">
Title
</div>
<div class="grid small-thumb">
Title
</div>
<div class="grid big-thumb">
Title
</div>
<div class="grid small-thumb">
Title
</div>
<div class="grid small-thumb">
Title
</div>
</div>

CSS

#blog-posts {
-moz-column-count: 1;
-webkit-column-count: 1;
column-count: 1;
-moz-column-gap: 0em;
-webkit-column-gap: 0em;
column-gap: 0em;
}

.grid {
background: #eee;
float: left;
position: relative;
color: #fff;
}

.big-thumb {
width: 50%;
height: 600px;
background: #aeaeae;
}

.small-thumb {
width: 25%;
height: 300px;
background: #353535;
}

最佳答案

要复制该网格,您可以制作具有 flex 子项的 flex 行,这些子项也是用于保存图像的 flex 列。

.flex {
display: flex;
}
.col {
flex-direction: column;
flex: 0 0 50%;
}
img {
max-width: 100%;
vertical-align: top;
}
<div class="flex row">
<div class="flex col">
<div class="big">
<img src="http://1.bp.blogspot.com/-hNC-oT6f-fY/TeXxO26yjvI/AAAAAAAAAOY/qfkOqdKkBi8/s1600/platon-photographer-putin-man-of-the-year-portrait.jpg">
</div>
<div class="flex row">
<div class="small">
<img src="/image/2C22p.jpg">
</div>
<div class="small">
<img src="/image/2C22p.jpg">
</div>
</div>

</div>
<div class="flex col">
<div class="flex row">
<div class="small">
<img src="/image/2C22p.jpg">
</div>
<div class="small">
<img src="/image/2C22p.jpg">
</div>
</div>
<div class="big">
<img src="http://1.bp.blogspot.com/-hNC-oT6f-fY/TeXxO26yjvI/AAAAAAAAAOY/qfkOqdKkBi8/s1600/platon-photographer-putin-man-of-the-year-portrait.jpg">
</div>
</div>

好吧,这就是您使用常规 ol' html/css 的方式。但是因为你只想拥有一堆像这样自动布局的元素,所以使用 masonry

$('.masonry').masonry({
itemSelector: '.item',
columnWidth: '.small'
});
body {
margin: 0;
}
.item {
float: left;
}
.big {
width: 50%;
}
.small {
width: 25%;
}
img {
width: 100%;
vertical-align: top;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js"></script>
<div class="masonry">
<div class="item big">
<img src="http://1.bp.blogspot.com/-hNC-oT6f-fY/TeXxO26yjvI/AAAAAAAAAOY/qfkOqdKkBi8/s1600/platon-photographer-putin-man-of-the-year-portrait.jpg">
</div>
<div class="item small">
<img src="/image/2C22p.jpg">
</div>
<div class="item small">
<img src="/image/2C22p.jpg">
</div>

<div class="item big">
<img src="http://1.bp.blogspot.com/-hNC-oT6f-fY/TeXxO26yjvI/AAAAAAAAAOY/qfkOqdKkBi8/s1600/platon-photographer-putin-man-of-the-year-portrait.jpg">
</div>
<div class="item small">
<img src="/image/2C22p.jpg">
</div>
<div class="item small">
<img src="/image/2C22p.jpg">
</div>
</div>

关于html - 地铁网格样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45196628/

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