Forum Moderators: open
What is the best way to code a responsive table when you want 6 columns to show on desktop, 4 columns to show on tablet/ipad, and 1 or 2 columns to show on a smartphone?
I know it’s a DIV solutionIt doesn’t have to be. In the same way that you can say
div.myclass {display: table-cell;}
you can say table.myclass tr {display: block; margin-top: 1em;}
table.myclass td {display: block; margin-left: 1em;}
and so on, making much use of nth-child selectors to give each successive cell a deeper indent--not too deep, of course, if you’re viewing on a small device! Put it inside an @media rule, depending on viewport width. I don't do this often, but have resorted to it a few times, mainly for multilingual text.