|
|
|
|
|
by likeclockwork
729 days ago
|
|
I don't know what the intended treatment of the text is, but did you consider using an img element and stacking the text on top of it? What you have is basically just an image element with width: 100 height: auto, but it has children. Here's an example, written with tailwind for my convenience but should be pretty legible to anyone who knows CSS: <div class="grid place-items-center [&>*]:[grid-area:1/1]">
<img
src="https://picsum.photos/500/400?grayscale&blur=2"
class="w-full h-auto"
/>
<div>Hello.</div>
</div>
<div class="grid place-items-center [&>*]:[grid-area:1/1]">
<img
src="https://picsum.photos/500/400?grayscale&blur=2"
class="w-full h-auto"
/>
<div>Hello.</div>
</div>
<div class="grid place-items-center [&>*]:[grid-area:1/1]">
<img
src="https://picsum.photos/500/400?grayscale&blur=2"
class="w-full h-auto"
/>
<div>Hello.</div>
</div>
The height of the container is governed by the height of the image (until the text becomes taller than the image). You still have fully fleixible in terms placement (place-self) and/or sizing (height: 100%) of the text container. |
|