I've been trying to create a simple (on paper) layout for a few days, but I cannot manage to get what I actually want.
Here's my current code:
<div class="mx-auto inline-flex items-center gap-8">
<!-- Left part -->
<div>
<div
class="flex snap-x snap-mandatory gap-8 overflow-x-auto py-4 child:snap-start"
>
<div class="flex min-w-full flex-col gap-4 rounded-3xl bg-gray-700 p-8">
<h3 class="text-xl font-medium">My card 1 title: a short text</h3>
<p class="text-lg text-gray-200">
This is a long description text that takes about two lines on a regular 1080p screen
</p>
</div>
<div class="flex min-w-full flex-col gap-4 rounded-3xl bg-gray-700 p-8">
<h3 class="text-xl font-medium">My card 2 title: a short text</h3>
<p class="text-lg text-gray-200">
This is a long description text that takes about two lines on a regular 1080p screen
</p>
</div>
<div class="flex min-w-full flex-col gap-4 rounded-3xl bg-gray-700 p-8">
<h3 class="text-xl font-medium">My card 3 title: a short text</h3>
<p class="text-lg text-gray-200">
This is a long description text that takes about two lines on a regular 1080p screen
</p>
</div>
</div>
</div>
<!-- Right part -->
<div class="aspect-square self-stretch">
<div
class="relative flex h-full w-full items-center justify-center rotate-12"
>
<div
style="transform: translateY(-40%);"
class="group absolute flex aspect-square h-1/2 items-center justify-center rounded-full bg-gray-400/75 transition-all duration-700 hover:bg-gray-600 hover:scale-105"
>
<img
src="https://picsum.photos/200?random=1"
alt="Card 1 icon"
class="w-1/2 transition-all duration-700 -rotate-12 group-hover:fill-dominant group-hover:scale-105"
/>
</div>
<div
style="transform: translate(-45%, 40%);"
class="group absolute flex aspect-square h-1/2 items-center justify-center rounded-full bg-gray-400/75 transition-all duration-700 hover:bg-gray-600 hover:scale-105"
>
<img
src="https://picsum.photos/200?random=2"
alt="Card 2 icon"
class="w-1/2 transition-all duration-700 -rotate-12 group-hover:fill-dominant group-hover:scale-105"
/>
</div>
<div
style="transform: translate(45%, 40%);"
class="group absolute flex aspect-square h-1/2 items-center justify-center rounded-full bg-gray-400/75 transition-all duration-700 hover:bg-gray-600 hover:scale-105"
>
<img
src="https://picsum.photos/200?random=3"
alt="Card 3 icon"
class="w-1/2 transition-all duration-700 -rotate-12 group-hover:fill-dominant group-hover:scale-105"
/>
</div>
</div>
</div>
</div>
Current status
The left part is okay, but I cannot manage to define the sizing of the right part correctly. Currently, it's size is 0x0 (without self-stretch
). I want its height to be the same as the left part (or their container) and its width to be the same as its height (aspect-square
).
Criteria of what I want
- I want the right part to be sized dynamically, by getting the same height as the left part (or the container), and the width define by its ratio
- It must keep this squared layout (width == height, hence
aspect-square
) - The left part can be as long as it wants
- Both parts must not be the same width, each one should fit appropriately (see rules above)
- The container can be a grid or a flexbox, it doesn't matter, what works best
Things I've tried
- Grid with auto flow (leads to even columns)
- Grid with 2/3 for the left part and 1/3 for the right part (closest to what I want, but not dynamic enough)
- Flexbox (right part has a size of 0x0)
self-stretch
for the right part, that I recently found, but despite the height being set properly, the width is 0