So I am using Enquire.js to add and remove bootstrap's pre-defined css classes for my website. Here is what I have:
Some bootstrap HTML thumbnails:
<div class="row">
<div class="thumb thumb col-xs-12 col-md-3">
<a href="#" class="thumbnail">
<img src="..." class="img-rounded img-responsive" alt="...">
</a>
</div>
<div id ="thumb" class="thumb col-xs-12 col-md-3">
<a href="#" class="thumbnail">
<img src="..." class="img-rounded img-responsive" alt="...">
</a>
</div>
</div>
I have set up the enquire.js so that the thumbnail sizes resize based on screen size as such:
<script type="text/javascript">
var $info = $('.thumb');
enquire.register("(max-width: 480px)", {
match: function() {
$info.removeClass('col-xs-6');
$info.addClass('col-xs-12');
},
unmatch: function() {
$info.removeClass('col-xs-12');
$info.addClass('col-xs-6');
}
}).listen();
</script>
Problem:
The problem I am having is that the enquire.js code only kicks in once the screen size has been reduced to 480px or less.
So when the site is first loaded, the resize code won't work until I actually manually resize it down to 480px or lower and then you can see the resizing take place.
You can have a look at the site here