Hemakumar Kakaraparti
Hemakumar Kakaraparti

Reputation: 29

Bootstrap responsive grid layout

This is my Markup which is coded using twitter bootstrap fluid layout

<div class="row-fluid">
  <div class="span4">Col4</div>
  <div class="span8">Col8</div>
</div>

This is working fine in Landscape mode. But in portrait i want to change the grid; e.g. the first div should occupy 2 columns and the second div should occupy 10 columns.

<div class="row-fluid">
  <div class="span2">Col2</div>
  <div class="span10">Col10</div>
</div>

I thought of defining a new class as .row-colum {.span4;} in normal less file and using media query orientation:portrait overwrite .row-column {.span2;}. But i am getting less compilation error.

This is what i thought of doing

<div class="row-fluid">
  <div class="row-column">Col2</div>
  <div class="span10">Col10</div>
</div>

Is there any way which i can achieve this?

Upvotes: 2

Views: 1517

Answers (1)

hexist
hexist

Reputation: 5240

If you can't/dont want to get it working with LESS, you can always fall back to looking for resize events:

$(window).resize(function () {
    if ($(window).width() < 640) {
        $("#col1").removeClass("span4").addClass("span2");
        $("#col2").removeClass("span8").addClass("span10");
    } else {
        $("#col1").removeClass("span2").addClass("span4");
        $("#col2").removeClass("span10").addClass("span8");
    }
});

Upvotes: 2

Related Questions