困难的图像安排
我有六个图像需要在此特定布局中安排。我觉得我一直在玩这些事情,但还没有走得很远。这是一个WP项目,所以我使用了两个ACF中继器字段。每个中继器都有三张图像。我觉得我要这一切都错了,而且解决方案比我要走的路线要简单得多。有人知道我如何实现这一目标吗?任何帮助将不胜感激!!谢谢你!
<div class="container pt-5">
<div class="row">
<div class="col-6"><?php the_content(); ?></div>
<div class="col-6 image-grid">
<!-- first row -->
<div class="row justify-content-between image-grid__row-first">
<?php if (have_rows('image_grid_row_first')) : while (have_rows('image_grid_row_first')) : the_row('image_grid_row_first');
$image = get_sub_field('image');
?>
<img src="<?php echo $image['url']; ?>" alt="">
<?php endwhile;
endif; ?>
</div>
<!-- second-row -->
<div class="row justify-content-between image-grid__row-second">
<?php if (have_rows('image_grid_row_second')) : while (have_rows('image_grid_row_second')) : the_row('image_grid_row_second');
$image = get_sub_field('image');
?>
<img src="<?php echo $image['url']; ?>" alt="">
<?php endwhile;
endif; ?>
</div>
</div>
</div>
</div>
和CSS:
.image-grid {
img {
max-width: 22.5%;
object-fit: cover;
object-position: 50% 15%;
outline: 12px solid white;
height: 225px;
}
&__row-first {
img {
&:nth-of-type(3) {
max-width: 55%;
width: 100%;
height: 260px;
}
}
}
&__row-second {
position: relative;
bottom: 40px;
z-index: -1;
img {
&:nth-of-type(1) {
max-width: 55%;
width: 100%;
}
}
}
}
I've got six images that need to be arranged in this specific layout. I feel like I've been endlessly playing around with these but haven't gotten very far. This is a WP project, so I'm using two ACF repeater fields. Each repeater has three images. I feel like I'm going about this all wrong and there is a much simpler solution than the route I'm going. Anyone know how I can achieve this? Any help would be greatly appreciated!! Thank you!
<div class="container pt-5">
<div class="row">
<div class="col-6"><?php the_content(); ?></div>
<div class="col-6 image-grid">
<!-- first row -->
<div class="row justify-content-between image-grid__row-first">
<?php if (have_rows('image_grid_row_first')) : while (have_rows('image_grid_row_first')) : the_row('image_grid_row_first');
$image = get_sub_field('image');
?>
<img src="<?php echo $image['url']; ?>" alt="">
<?php endwhile;
endif; ?>
</div>
<!-- second-row -->
<div class="row justify-content-between image-grid__row-second">
<?php if (have_rows('image_grid_row_second')) : while (have_rows('image_grid_row_second')) : the_row('image_grid_row_second');
$image = get_sub_field('image');
?>
<img src="<?php echo $image['url']; ?>" alt="">
<?php endwhile;
endif; ?>
</div>
</div>
</div>
</div>
And the css:
.image-grid {
img {
max-width: 22.5%;
object-fit: cover;
object-position: 50% 15%;
outline: 12px solid white;
height: 225px;
}
&__row-first {
img {
&:nth-of-type(3) {
max-width: 55%;
width: 100%;
height: 260px;
}
}
}
&__row-second {
position: relative;
bottom: 40px;
z-index: -1;
img {
&:nth-of-type(1) {
max-width: 55%;
width: 100%;
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论