See how the content in the main area of the desktop view stays in place and the entire right column collapses underneath it?
I have seen a few examples online of doing a simple 2-column to 1-column switch, but what I have is “nested”.
The best idea I could come up with is to create a div for the main area and the side bar and treat them as two columns for the desktop and then collapse down so they are stacked for the mobile view. But I am not sure if that is “responsive” enough…
Looks reasonable. I would suggest that you should not set a width on both columns… just one. The other will be the difference between the table width and the column with the set width.
Looks OK. Just nit picking here, it should work as it is, but I will mention: Since you are using the “mobile first” approach, you don’t need the display: block for the two columns/sections, since block is the default display for those elements.
Also the wrapper table settings may be better placed in the media query, since it is not being displayed as a table in the mobile view.
You want it on the wrapper because displaying as a table, it will shrink to fit content otherwise. But do remove it from the two columns. Why?
If you only set one, and they are both set to 100% before the query, the one you don’t re-set in the query will still want to be 100%. As table cells they will fill the wrapper whatever.
My thinking was that if you set each column to display: block that that would make each column “100% wide” and therefore adding width: 100% would be redundant. Follow my thinking?
If you are doing mobile first, the [future columns] will begin as block objects and not require a width. When the width is reached at which the two columns will be created, then {display:table-cell} and column width(s) would be applied. Your strategy sounds correct.
More clarification about table and column widths…
If the table uses {table-layout:fixed} and the table has a width assigned, then applying a width to one column is sufficient to establish the width of both columns.
If the table uses {table-layout:auto} and if column widths are assighed, then the sum of the widths of the columns must not exceed 100% and are basic starting points but can change if the content forces the width to change. In other words, the widths can shift as needed to accommodate the content. Classic table behavior.