I am facing a challenge with my side-by-side grid columns. I want the grid to always be the width of its container, ensuring that as much content from each column is visible as possible within that space.
In my demo, the grid is currently set at 300px wide with both columns being content editable for dynamic changes in length. Despite using
grid-template-columns: minmax(min-content, 1fr) minmax(min-content, 1fr);
, I have not been able to achieve the desired outcome.
When the total content width exceeds 300px, the grid overflows horizontally instead of automatically adjusting the column widths to fit accordingly:
https://i.sstatic.net/TcuT8.png
My goal is to constrain the grid's width to 300px and ensure that the widest cell shrinks enough to display as much content as possible from the smaller cell while applying overflow-x: ellipsis
.
This balancing act should occur both ways: shrinking wider cells until proportional balance is achieved.
The existing CSS properties don't seem to allow for this behavior without depending on JavaScript calculations or complex solutions.
If anyone has a CSS-only solution or an alternative approach that requires minimal JavaScript intervention, I would greatly appreciate your input.