困难的图像安排

发布于 2025-02-10 07:25:00 字数 2315 浏览 0 评论 0原文

我有六个图像需要在此特定布局中安排。我觉得我一直在玩这些事情,但还没有走得很远。这是一个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!
enter image description here

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文