2

I want to change the column order only in xs devices with bootstrap this is what i got

<div class="container">
<div class="row">
    <div class="col-lg-7 col-md-7 col-sm-7 col-xs-12">column left</div>
    <div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
        <div>Column right nro 1</div>
        <div>Column right nro 2</div>
    </div>
</div>

I want to focus on the right column, only in xs devices i need them to be inverted showing first column right nro 2 and then column right nro 1.

FIDDLE

aguisa
  • 343
  • 1
  • 5
  • 18

1 Answers1

3

One way to do it is using display: table and caption-side property and wrap those properties into xs-media rules:

@media (max-width: 768px) {
    .col-right {
        display: table;
    }
    .col-right > div:nth-child(2) {
        display: table-caption;
        margin: 0 15px;
    }
}

Demo: http://jsfiddle.net/fhn6b6gb/1/

dfsq
  • 191,768
  • 25
  • 236
  • 258
  • thanks, it worked. what could be other way to do it? – aguisa Dec 11 '14 at 23:38
  • This is a very clean and fast way. With CSS there's flexbox, if known heights, absolute positions or negative positive margins and other less elegant approaches than this answer. – Christina Dec 12 '14 at 14:45