I have two <divs>
(left-col, right-col) containing WordPress posts (the more recent, the lower the number)
left-col | right-col
--------------------
--post 1 | --post 2
--post 3 | --post 4
--post 5 | --post 6
Using @media
and CSS
I would like to convert this into a single column like this:
single-col
----------
--post 1
--post 2
--post 3
--post 4
etc.
Notice that I am not trying to push the right-col
under the left-col
but also change how the posts pile up.
Currently my s have following relevant values:
#left-col {
width: 420px;
float: left;
}
#right-col {
width: 420px;
float: left;
}
ALTERNATIVE QUESTION: is there any other way to get this two column layout flat for mobile screens, even if it needs more thank CSS/media query?
I’d solve this without the column divs and possibly use the nth-child css selector
Something like:
Demo on jsfiddle
Try using
jQuery
, it comes with some functions to manipulate the content ofdivs
, likeappend()
,replaceWith()
,insertAfter()
.You could move elements from one
div
to another, flush or appenddivs
.See the explanations to those function here:
append(),
replaceWith()
insertAfter()
You might wanna check W3Schools jQuery tutorial first, if you are unfamiliar with jQuery.