Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with chrome not calculating cell height/overflow correctly for nested grid #44

Open
martyns opened this issue Jun 5, 2018 · 5 comments

Comments

@martyns
Copy link

martyns commented Jun 5, 2018

I have a pretty simple header/content/footer grid setup with an additional sidebar column. That sidebar is made of another grid containing it's own header and content cells. I want the two content areas (main and sidebar) to scroll vertically and never overflow the parent grid's height.

Please see: https://codepen.io/martyns/pen/JZXgEj

In Firefox the .sidebar-content div shows a vertical scrollbar (which it how I want it to look and behave) while in Chrome there is no such scrollbar and the content overflows, and then forces the parent grid to overflow horribly.

Anyone see this issue before and/or have any ideas of a simple workaround?

@jwdunn1
Copy link

jwdunn1 commented Jun 5, 2018

As a workaround, for both browsers, try setting the .sidebar class to grid-template-rows: 20px 170px; The 170px accounts for the original fixed height of 200px minus the header and border.

@martyns
Copy link
Author

martyns commented Jun 6, 2018

@jwdunn1 Thanks for that suggestion, that does seem to work for the example. Unfortunately the real-world situation this was inspired by is a bit more dynamic and the height of the main .container, and therefore also the .sidebar is dynamic so I can't hard-code the height in the css is this way.

I tried using calc but that doesn't make a difference to the rendering i.e.

grid-template-rows: 20px calc(100% - 20px);

@jwdunn1
Copy link

jwdunn1 commented Jun 6, 2018

Perhaps an alternative workaround: remove the nested grid.
From the .sidebar remove:
display: grid; grid-template-rows: 20px auto; height: 100%; max-height: 100%
And add: overflow: auto;
Then add position: sticky; and top: 0; to the .sidebar-header;
See forked example: https://codepen.io/anon/pen/vrXYQq

@martyns
Copy link
Author

martyns commented Jun 6, 2018

@jwdunn1 Thanks again. That definitely works, just a shame we have to live with the scrollbar in the sidebar header but close enough I think 👍.

Interestingly, I tried to workaround the issue with flexbox: https://codepen.io/anon/pen/eKdzzv but it has the exact same issue (i.e. works in Firefox but overflows in Chrome/Edge).

@jwdunn1
Copy link

jwdunn1 commented Jun 6, 2018

@martyns To remove the scrollbar in the sidebar header, I made a few more adjustments (works in Chrome and Firefox): https://codepen.io/anon/pen/dKpXKw (Basically, removing the .sidebar division and reassigning the sidebar header and content into their own cells of the original grid.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants