Make table narrower than desktop container width plus responsive on mobile?
-
Hi Tobias. Here’s the second question in my series about my first go-round with TablePress.
This is what I want to achieve:
Desktop
– narrower than full container width
– EVENTUALLY, centered
– EVENTUALLY, columns of different widths to accommodate different contentMobile
– full screen width
– text wrapping
– no horizontal scrollingI will focus in this request on making the table 1) narrower than the full container width on desktop, and 2) full screen width on mobile without needing horizontal scrolling.
My site is running the Enfold theme. My container width is 1310px. In TablePress, I am using the DataTables JS library because I need sorting to be activated.
This is my page for testing TablePress:
https://www.missouriartscouncil.org/a_test-of-tablepressI have coded the tables with four different CSS options to regulate the width. For each of these options, I have coded horizontal scrolling Unchecked and checked. In summary:
1 – no CSS; TablePress default of 100% container width; scrolling UNchecked
1a – scrolling checked
2 – width 100%; scrolling UNchecked
2a – scrolling checked
3 – width 1000px; scrolling UNchecked
3a – scrolling checked
4 – width 75%; scrolling UNchecked
4a – scrolling checkedNOTE: I don’t want to use horizontal scrolling on mobile, but I built tables with that option to see what would happen.
CSS for 2&2a, 3&3a, 4&4a
.dataTables_wrapper .tablepress-id-2 {
width: 100% !important;
}
(And id-6, which is 2a).dataTables_wrapper .tablepress-id-3 {
width: 1000px !important;
}
(and id-7, which is 3a)
.dataTables_wrapper .tablepress-id-4 {
width: 75% !important;
}
(and id-8, which is 4a)As you’ll see when you view the test page, results were wildly disparate.
I can get the result on mobile that I want – full screen width, text wrapping, no scrolling – only if on desktop the table is full container width. (Tables 1, 1a, 2, and 2a)
(NOTE: On 2a, scrolling is checked, but it is not showing up. Huh?)If I try narrowing the table on desktop via pixels, I get weird results (Tables 3 and 3a):
– scrolling Unchecked, desktop narrows (yay!), but mobile’s columns are so wide they run off the screen
– scrolling checked, desktop does not narrow (remains full container width), mobile is perfect BUT there is no scrolling even though scrolling is checked (huh?)If I try narrowing the table on desktop via percentages, I also get weird results (Tables 4 and 4a):
– scrolling Unchecked, desktop narrows (yay!), but scrolling DOES show up (huh?), and the columns run off the screen
– scrolling checked, table’s header on desktop is narrower than the columns, mobile’s scrolling does NOT show up (huh?), table is narrower than full screen widthIn sum
Not one of the eight combinations of CSS code and scrolling checked/unchecked results in this:Desktop
– narrower than full container widthMobile
– full screen width
– text wrapping
– no horizontal scrollingI’m not even talking yet about some of the other things I want:
– table centered on desktop
– border around the table going all the way around instead of only the top and the left side
– no “edit” capability for the user on the front end (see lower left corner of tables)For those, later! ??
The page I need help with: [log in to see the link]
- The topic ‘Make table narrower than desktop container width plus responsive on mobile?’ is closed to new replies.