I have a 2x3 grid, consisting of 1 2x1 and 4 1x1 elements. I want to show the whole 2x1 cell, and make the 1x1 cells y-scrollable for anything past the min-content height of the 2x1 cell. That is to say, I want the whole grid to be the minimum height that it takes for the 2x1 cell not to overflow. Is there any way I can achieve this? Currently, I am using grid
.
:not(html, body, .container) {
padding: .5em;
border: 1px solid goldenrod;
border-radius: .25em;
}
.container {
display: grid;
grid:
"chart details-a details-b" 200px
"chart details-c details-d" 200px
/ 1fr 2fr 2fr;
gap: .5em;
}
.chart {
grid-area: chart;
}
[class^=details] {
overflow-y: auto;
}
.details-a {
grid-area: details-a;
}
.details-b {
grid-area: details-b;
}
.details-c {
grid-area: details-c;
}
.details-d {
grid-area: details-d;
}
<div >
<div >
this
<br>
thing
<br>
here
<br>
must
<br>
be
<br>
a
<br>
chart
<br>
but
<br>
is
<br>
it
<br>
a
<br>
chart
</div>
<div >
We need to crystallize a plan business impact strategic high-level 30,000 ft view our competitors are jumping the shark. Gain traction UI, but game-plan. Can you run this by clearance? hot johnny coming through . Canatics exploratory investigation data masking 360 degree content marketing pool but conversational content so streamline you better eat a reality sandwich before you walk back in that boardroom. Unlock meaningful moments of relaxation red flag cta yet message the initiative, and blue sky thinking we can't hear you . When does this sunset? pulling teeth a better understanding of usage can aid in prioritizing future efforts onward and upward, productize the deliverables and focus on the bottom line we need to make the new version clean and sexy. Agile commitment to the cause yet closer to the metal so pipeline, yet land the plane for quick win, but shoot me an email. In an ideal world take five, punch the tree, and come back in here with a clear head we want to see more charts you gotta smoke test your hypothesis or you must be muted for paddle on both sides. Service as core &innovations as power makes our brand herding cats, so quick win, for high-level, for horsehead offer. Good optics increase the pipelines. We need a paradigm shift. This is not the hill i want to die on. We need to make the new version clean and sexy circle back but due diligence best practices i'm sorry i replied to your emails after only three weeks, but can the site go live tomorrow anyway? and 360 degree content marketing pool. Have bandwidth deploy to production but hit the ground running nor 60% to 30% is a lot of persent nor if you're not hurting you're not winning business impact and poop. Currying favour let's take this conversation offline nor that is a good problem to have this is a no-brainer anti-pattern. Have bandwidth workflow ecosystem yet drill down, net net.
</div>
<div >
I'm baby knausgaard synth farm-to-table, squid paleo woke slow-carb four loko street art cronut iPhone butcher humblebrag direct trade hella. Salvia coloring book cornhole cloud bread migas glossier microdosing leggings cray live-edge distillery yuccie ennui swag. Pinterest subway tile actually fixie, lo-fi prism poke taxidermy tofu. Helvetica activated charcoal roof party shaman wayfarers drinking vinegar stumptown tacos man braid small batch actually direct trade. Migas gentrify tumeric salvia gluten-free slow-carb swag. Raw denim umami authentic thundercats fanny pack, locavore four dollar toast polaroid vexillologist quinoa lo-fi poutine. Fixie biodiesel everyday carry YOLO humblebrag. Bushwick offal brunch green juice, messenger bag tattooed freegan truffaut iceland banjo. Bitters everyday carry typewriter letterpress cardigan franzen. Hexagon cray lomo stumptown keytar, normcore drinking vinegar helvetica polaroid 8-bit VHS mlkshk shabby chic. Slow-carb stumptown man bun copper mug, mlkshk vinyl succulents poutine mixtape health goth fanny pack cornhole roof party. IPhone occupy put a bird on it kale chips, tacos artisan salvia cold-pressed marfa selvage tote bag. Messenger bag small batch affogato kickstarter, pork belly adaptogen drinking vinegar vinyl bicycle rights truffaut. Meditation lumbersexual sustainable wolf, semiotics YOLO chartreuse. Seitan fixie venmo truffaut gluten-free master cleanse chambray raclette prism, cliche af DIY cray fanny pack. Single-origin coffee 3 wolf moon salvia, shoreditch vegan put a bird on it kogi leggings sriracha retro yuccie man bun green juice live-edge cred. Ethical raclette sustainable chambray you probably haven't heard of them squid.
</div>
<div >
Okay, hello, it's the Martian. Young money. Excuse my charisma, vodka with a spritzer. So misunderstood but what's the world without enigma? I lost my mind, it's somewhere out there stranded. I need a Winn-Dixie bag full of money right now to the VIP section. Just talked to moms, told her she the sweetest. Talking to myself because I am my own consultant. Paper chasin', tell that paper "Look, I'm right behind ya." Real G's move in silence like lasagna. People say I'm borderline crazy, sorta kinda. Got the Maserati dancing on the bridge. You pop'em cause we pop'em like Orville Redenbacher. But what should I scream for? This is my theme park. You're a goon but what's a goon to a goblin? I don't owe you like two vowels. Even Gwen Stefani said she couldn't doubt me. Met a female dragon, had a fire conversation. Approving million-dollar deals from my iPhone. Flyer than Beetlejuice, Beetlejuice, Beetlejuice. I got summer hating on me cause I'm hotter than the sun. Got Spring hating on me cause I ain't ever sprung. I parallel park in that red-and-yellow thing, old school Atlanta Hawk. And my chain Toucan Sam, that tropical colors, you can't match that, gotta be abstract. Quick Draw McGraw, I went to art school. I'm about to go Andre the Giant. Gotta handful of stacks, better grab an umbrella. I'm counting all day like a clock on the wall. I'm too clean for the choir.
</div>
<div >
Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro. De carne lumbering animata corpora quaeritis. Summus brains sit, morbo vel maleficia? De apocalypsi gorger omero undead survivor dictum mauris. Hi mindless mortuis soulless creaturas, imo evil stalking monstra adventus resi dentevil vultus comedat cerebella viventium. Qui animated corpse, cricket bat max brucks terribilem incessu zomby. The voodoo sacerdos flesh eater, suscitat mortuos comedere carnem virus. Zonbi tattered for solum oculi eorum defunctis go lum cerebro. Nescio brains an Undead zombies. Sicut malus putrid voodoo horror. Nigh tofth eliv ingdead.
</div>
</div>
What I have:
______
|@|a|b|
|@|a|b|
| |c|d|
|_|c|d|
What I want:
______
|@|a|b|
|@|c|d|
CodePudding user response:
Given that HTML structure you can make your own 'grid' by first ensuring container has the height of chart by positioning that relative within container but then positioning the other elements absolute.
Positions and dimensions are calculated involving a CSS variable which holds the desired gap between elements.
* {
margin: 0;
}
:not(html, body, .container) {
padding: .5em;
border: 1px solid goldenrod;
border-radius: .25em;
box-sizing: border-box;
}
.container {
--gap: .5em;
--hg: calc(var(--gap) / 2);
position: relative;
display: inline-block;
width: 100vw;
}
.container>* {
margin: 0;
}
.chart {
grid-area: chart;
width: calc(20% - var(--hg));
}
[class^=details] {
overflow-y: auto;
position: absolute;
height: calc(50% - var(--hg));
width: calc(40% - (var(--hg) * 3 / 2));
display: inline-block;
overflow: auto;
}
.details-a {
top: 0;
left: calc(20% var(--hg));
}
.details-b {
top: 0;
right: 0;
}
.details-c {
bottom: 0;
left: calc(20% var(--hg));
}
.details-d {
bottom: 0;
right: 0;
}
<div >
<div >
this
<br> thing
<br> here
<br> must
<br> be
<br> a
<br> chart
<br> but
<br> is
<br> it
<br> a
<br> chart
</div>
<div >
We need to crystallize a plan business impact strategic high-level 30,000 ft view our competitors are jumping the shark. Gain traction UI, but game-plan. Can you run this by clearance? hot johnny coming through . Canatics exploratory investigation data
masking 360 degree content marketing pool but conversational content so streamline you better eat a reality sandwich before you walk back in that boardroom. Unlock meaningful moments of relaxation red flag cta yet message the initiative, and blue
sky thinking we can't hear you . When does this sunset? pulling teeth a better understanding of usage can aid in prioritizing future efforts onward and upward, productize the deliverables and focus on the bottom line we need to make the new version
clean and sexy. Agile commitment to the cause yet closer to the metal so pipeline, yet land the plane for quick win, but shoot me an email. In an ideal world take five, punch the tree, and come back in here with a clear head we want to see more charts
you gotta smoke test your hypothesis or you must be muted for paddle on both sides. Service as core &innovations as power makes our brand herding cats, so quick win, for high-level, for horsehead offer. Good optics increase the pipelines. We need
a paradigm shift. This is not the hill i want to die on. We need to make the new version clean and sexy circle back but due diligence best practices i'm sorry i replied to your emails after only three weeks, but can the site go live tomorrow anyway?
and 360 degree content marketing pool. Have bandwidth deploy to production but hit the ground running nor 60% to 30% is a lot of persent nor if you're not hurting you're not winning business impact and poop. Currying favour let's take this conversation
offline nor that is a good problem to have this is a no-brainer anti-pattern. Have bandwidth workflow ecosystem yet drill down, net net.
</div>
<div >
I'm baby knausgaard synth farm-to-table, squid paleo woke slow-carb four loko street art cronut iPhone butcher humblebrag direct trade hella. Salvia coloring book cornhole cloud bread migas glossier microdosing leggings cray live-edge distillery yuccie
ennui swag. Pinterest subway tile actually fixie, lo-fi prism poke taxidermy tofu. Helvetica activated charcoal roof party shaman wayfarers drinking vinegar stumptown tacos man braid small batch actually direct trade. Migas gentrify tumeric salvia
gluten-free slow-carb swag. Raw denim umami authentic thundercats fanny pack, locavore four dollar toast polaroid vexillologist quinoa lo-fi poutine. Fixie biodiesel everyday carry YOLO humblebrag. Bushwick offal brunch green juice, messenger bag
tattooed freegan truffaut iceland banjo. Bitters everyday carry typewriter letterpress cardigan franzen. Hexagon cray lomo stumptown keytar, normcore drinking vinegar helvetica polaroid 8-bit VHS mlkshk shabby chic. Slow-carb stumptown man bun copper
mug, mlkshk vinyl succulents poutine mixtape health goth fanny pack cornhole roof party. IPhone occupy put a bird on it kale chips, tacos artisan salvia cold-pressed marfa selvage tote bag. Messenger bag small batch affogato kickstarter, pork belly
adaptogen drinking vinegar vinyl bicycle rights truffaut. Meditation lumbersexual sustainable wolf, semiotics YOLO chartreuse. Seitan fixie venmo truffaut gluten-free master cleanse chambray raclette prism, cliche af DIY cray fanny pack. Single-origin
coffee 3 wolf moon salvia, shoreditch vegan put a bird on it kogi leggings sriracha retro yuccie man bun green juice live-edge cred. Ethical raclette sustainable chambray you probably haven't heard of them squid.
</div>
<div >
Okay, hello, it's the Martian. Young money. Excuse my charisma, vodka with a spritzer. So misunderstood but what's the world without enigma? I lost my mind, it's somewhere out there stranded. I need a Winn-Dixie bag full of money right now to the VIP
section. Just talked to moms, told her she the sweetest. Talking to myself because I am my own consultant. Paper chasin', tell that paper "Look, I'm right behind ya." Real G's move in silence like lasagna. People say I'm borderline crazy, sorta kinda.
Got the Maserati dancing on the bridge. You pop'em cause we pop'em like Orville Redenbacher. But what should I scream for? This is my theme park. You're a goon but what's a goon to a goblin? I don't owe you like two vowels. Even Gwen Stefani said
she couldn't doubt me. Met a female dragon, had a fire conversation. Approving million-dollar deals from my iPhone. Flyer than Beetlejuice, Beetlejuice, Beetlejuice. I got summer hating on me cause I'm hotter than the sun. Got Spring hating on me
cause I ain't ever sprung. I parallel park in that red-and-yellow thing, old school Atlanta Hawk. And my chain Toucan Sam, that tropical colors, you can't match that, gotta be abstract. Quick Draw McGraw, I went to art school. I'm about to go Andre
the Giant. Gotta handful of stacks, better grab an umbrella. I'm counting all day like a clock on the wall. I'm too clean for the choir.
</div>
<div >
Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro. De carne lumbering animata corpora quaeritis. Summus brains sit, morbo vel maleficia? De apocalypsi gorger omero undead survivor dictum mauris. Hi mindless mortuis soulless creaturas,
imo evil stalking monstra adventus resi dentevil vultus comedat cerebella viventium. Qui animated corpse, cricket bat max brucks terribilem incessu zomby. The voodoo sacerdos flesh eater, suscitat mortuos comedere carnem virus. Zonbi tattered for
solum oculi eorum defunctis go lum cerebro. Nescio brains an Undead zombies. Sicut malus putrid voodoo horror. Nigh tofth eliv ingdead.
</div>
</div>
CodePudding user response:
You can make use of grid-row
and grid-column
properties in relation to your initial template for columns.
.wrapper {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
.wrapper > .special:nth-child(1) {
grid-column: 1;
grid-row: 1;
}
.wrapper > .special:nth-child(2) {
grid-column: 1;
grid-row: 2;
}
<div >
<div >@</div>
<div >@</div>
<div >A</div>
<div >B</div>
<div >C</div>
<div >D</div>
</div>