Skip to content

Display images in a 2-column grid on mobile, just like on desktop #2018

Closed Answered by delucis
hooziwang asked this question in Q&A
Discussion options

You must be logged in to vote

For something like this, it might be best to make a custom grid component that gives you full flexibility, for example:

---
// src/components/TwoColumnGrid.astro
---

<div class="my-grid">
  <slot />
</div>

<style>
.my-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
</style>

Then in your content you can use this:

import TwoColumnGrid from '/src/components/TwoColumnGrid.astro';

<TwoColumnGrid>
[![](/1.webp)](/url_1/)
[![](/2.webp)](/url_2/)
[![](/3.webp)](/url_3/)
</TwoColumnGrid>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by delucis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants