My goal here is to have a table which displays normally on large screens, but when the screen is smaller than $minTableWidth, it should become scrollable, and the component which it is wrapped in should continue to get smaller and display mobile friendly, ie only the table should be scrollable.
Here’s what I have so far:
<div>
<div>other parts of the page, etc...</div>
<div className={styles.tableWrapperOuter}>
<div className={styles.tableWrapperInner}>
<Table className={styles.applicationTable}>
{renderTableHeader()}
<TableBody>{renderTableContent()}</TableBody>
</Table>
</div>
</div>
</div>
.tableWrapperOuter {
width: 100% //if screen is large, take up the full size
@media screen and (max-width: $minTableWidth) { //if the screen is small, add scroll
overflow-x: auto;
}
}
.tableWrapperInner {
min-width: 900px; //force the table to be normal size
}
.tableRowTemplate {
grid-template-columns: minmax(100px, 1fr) minmax(80px, 1fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(80px, 1fr) 80px 10px;
}
I’ve experimented with various combinations but am absolutely stuck on this, so would appreciate any/all tips
2
Answers
The solution for me was to use the 'vw' on the outer wrapper. Then I could set the width on the inner element to a pre-defined width on small screens in the inner wrapper
Try this: