I have a two-column bootstrap layout: a main content column and a sidebar column on the right.
On big enough screens, both sidebar DIVs (abovemain and belowmain) are to be shown to the right of the main content.
On smaller screens, I want one part of the sidebar (abovemain) to be displayed above the main content, the rest of it (belowmain) below the main content.
Expected Result on a big enough screen:
Column 1 | Columm 2
-------------- | ---------------------------------------
Main Main Main | Above Main Content or Side (X)
Main Main Main | ---------------------------------------
Main Main Main | Below Main Content or Side
Expected Result on a small screen:
Above Main Content or Side (X)
---------------------------------
Main Main Main
Main Main Main
Main Main Main
Main Main Main
---------------------------------
Below Main Content or Side
<div class="row">
<div class="col-md-12 narrow">Above Main Content or Side (X)</div>
<div class="col-md-8">Main Content</div>
<div class="col-md-4">
<div class="abovemain">Above Main Content or Side (X)</div>
<div class="belowmain">Below Main Content or Side</div>
</div>
</div>
My terrible solution so far: repeating the output (X), one time into the "narrow"-DIV, a second time into the "abovemain"-DIV, then hide one or the other by css according to the media-width:
.narrow { display:none; }
.abovemain { display:block; }
@media (max-width: 800px) {
.narrow { display:block; }
.abovemain { display:none; }
}
Do you know a no-script-solution where the output doesn't have to be repeated?