I'm looking to create a CSS Grid layout where the grandchild element stretches to fit the width of its parent.
Here's a demo showcasing my issue -> https://play.tailwindcss.com/jZdsHpPAad
The CSS Grid Wrapper I have is as follows:
<div class="wrapper grid grid-cols-[1fr,70px,min(70ch,calc(100%-64px)),70px,1fr] gap-8 mb-24">
<div class="mt-24 col-[3/4]">
<dl>
<dt class="sr-only">Published on</dt>
<dd class="mb-2 font-medium text-gray-500 dark:text-gray-400">
<time datetime="2021-07-14T11:46:03.123Z">July 14, 2021</time>
</dd>
</dl>
<ShiftBy x="{-2}">
<h1 class="text-5xl font-alegreya">20 More Mindfuck Movies For The Brain Scrambling Experience</h1>
</ShiftBy>
</div>
<div class="prose dark:prose-light col-[3/4]">
<p class="sw-para">The predecessor to this list of mindfuck feature films showcased the average mind-numbing and quasi-discomposing stories from some great film makers. While you relished <a href="http://www.scoopwhoop.com/entertainment/20-mindfuck-hollywood-movies/" target="_blank">the previous list</a>, we felt we should explore different aspects and shades of an epic mindfuck. From the uneasy viewing to the unsettling, the 'what did I just watch' to the 'why did I just watch this', here's a renewed thought-blender list we compiled for you.</p>
<h2>1. Neco Z Alenky/Alice (1988) </h2>
<p class="sw-para">A surreal and almost grimy adaptation of <i>Alice In Wonderland, </i>Czech director Jan Svankmajer managed to come up with a low budget film with a unique perspective on retelling the story and far from elaborate filming devices like stop motion and dark lighting. <i>Alice</i> is a complete trip.</p>
<figure class="sw-media col-[2/5]">
<!-- col-[2-5] doesn't work -->
<img src="https://image.scoopwhoop.com/w620/s3.scoopwhoop.com/anj/jf/946880113_3.jpg.webp" data-src="https://s3.scoopwhoop.com/anj/j...
The grid has 5 columns defined by
grid-cols-[1fr,70px,min(70ch,calc(100%-64px)),70px,1fr]
I want to center my layout within min(70ch,calc(100%-64px))
, with only images stretching outside it in
70px,min(70ch,calc(100%-64px)),70px
All content is within the 3/4
column.
My goal is to have images span the 2/5
column, but due to being a grandchild element, it's not working as intended. I need this setup because I'm using @tailwindcss/typography
, which requires the prose
class at the top.
Any suggestions on how to make the figure
use the 2/5
column effectively within the constraints? If a solution in CSS Grid isn't feasible, utilizing flex
or other methods are also welcomed.