Responsive layout
-
I am working on a theme which needs to show posts/pages in small blocks in a multi-column layout, so the most important ones appear at the top, hence on a three column layout we have
1 2 3
4 5 6
7 8 9
i.e. NOT newspaper-like columns; but on smaller devices, e.g. an iPhone, we have
1
2
3
4
…The blocks are of variable length (and even if they weren’t, they will be expandable in situ so would become so), so floated div’s won’t do the job (row 2 would start at the bottom of the longest in row 1 and be pushed down when any column in row 1 were expanded vertically).
Also, I don’t know how many columns I’ll need server side. Yes, I could look at the browser signature, but I’d rather do it on the basis of available space.
My initial thought involves doing it in Javascript, so I generate div’s for each post, initially inside one content column, and then shuffle them into additional content columns (probably longer floated div’s) as necessary in the browser. But this will mean a period when the display looks a bit odd, until it has all loaded. Maybe starting off with three and shuffling to one might be better because typically you won’t see beyond the first on a small screen.
I suppose if I knew server-side how many columns I needed *and* could shuffle, or buffer content, of the posts in the loop, I could solve it server side, but that seems fraught with problems.
Does anyone have any other ideas about how I could generate generic (i.e. not knowing how many columns there are in advance) HTML which I could adjust with CSS according to the device characteristics?
- The topic ‘Responsive layout’ is closed to new replies.