Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap: Dyamic columns with container-fluid and row not wrapping properly

Here's what I'm currently seeing:

http://arsenalist.com/f/embed/index.html

Notice that the second row isn't wrapping properly. The code looks like:

<div class="container-fluid">
    <div class="row clearfix">
        <div class="col-md-2 bit clearfix">
            <div class="clearfix">
                <div class="image-preview">
                    <a href=""><img src="" class="img-rounded img-responsive"/></a>
                </div>
                <h6><a href="">Some text</a></h6>
            </div>
        </div>
    </div>
    .... repeat ....
</div>

Any idea why the wrapping is incorrect?

like image 956
Nightwolf Avatar asked Mar 19 '23 20:03

Nightwolf


1 Answers

OK, I figured it out. It's more of an RTFM thing with responsive column resets. You basically can use just one <div class="row"> and put all the columns in it (even if they end up appearing on different rows), as long as you put in the proper clear at the right position, e.g., <div class="clearfix visible-xs-block"></div>. So in the below example, I'm displaying two columns on XS viewports, 6 columns on large and medium viewports, and 4 columns on small view ports.

<div class="container-fluid">
<div class="row">
{% for b in bits %}
    <div class="col-xs-6 col-md-2 col-lg-2 col-sm-3 bit">
        <h6><a target="_top" href="{{b.link}}">{{b.description}} </a></h6>
    </div>
    {% if loop.index is divisibleby 2 %}
        <div class="clearfix visible-xs-block"></div>
    {% endif %}
    {% if loop.index is divisibleby 4 %}
        <div class="clearfix visible-sm-block"></div>
    {% endif %}
   {% if loop.index is divisibleby 6 %}
        <div class="clearfix visible-md-block"></div>
        <div class="clearfix visible-lg-block"></div>
    {% endif %}
{% endfor %}
</div>
like image 174
Nightwolf Avatar answered Mar 21 '23 08:03

Nightwolf