Closed spentacular closed 6 years ago
I'm no expert but I actually think that's quite a cool solution. I don't understand why you need the wrapper on the scrolling div though. Here I forked yours and moved the scrollable
class to the main
grid-item:
Here I added overflow: hidden
to the body
and removed the sticky
class. I also removed height: 100%
from the scrollable
class because it seemed to break your overflow. I'm testing on Chrome 65.
I see in your image that you actually want the sidebar
and the main
to scroll together?
@IOIIOOIO I added the wrapping scrollable div
because we had a few areas where we have a sticky header in the main section so only it's content would be scrollable. Kind of like Spectrum's layout:
Yep, that height
definitely was breaking it, doh!
And both the sidebar/main can scroll independently, I know that would probably require some kind of scroll sync JS hacks to make that work better.
@IOIIOOIO doh, a lot easier than I realized.
On any grid-area
, as long as you cause it to need block formatting context then it won't fill the area with the height/width
of the content.
Here's a rough example:
https://codepen.io/spentacular/pen/QmBaGy
You could definitely bring up the grid so it's only at the .App
level, but I'm just playing around with a couple of ideas right now.
Absolute was doing the same thing above, causing the block formatting context
, but I find the hidden way a bit less hacky (and I think it will work in IE11, it doesn't like the absolute way).
I'm trying to create a layout where everything is contained within the viewport and children scroll when they overflow. It doesn't appear that a child item in a grid with a
height: 100%
ormax-height: 100%
only fills the parent:I can achieve it if a set a div in a
grid-area
and then absolute position that element inside it:https://codepen.io/spentacular/pen/MVbEva?editors=0100
How would you go about creating this type of layout?
Thanks!