With twitter bootstrap.css and bootstrap-responsive.css, .span*
become equivalent to a .span12
under 768px
.
This behaviour is perfectly fine when text is embedded, but for pictures it make sense to use a 2x2
layout between 4x1
and 1x4
.
How to obtain this 2x2
layout from 767px
to 320px
?
768px wide (4x1)
767px wide (1x4)
HTML:
<div class="row-fluid">
<ul class="thumbnails">
<li class="span3">
<div class="thumbnail" href="#">
<img alt="" src="http://placehold.it/200x150">
<p>1</p>
</div>
</li>
<li class="span3">
<div class="thumbnail" href="#">
<img alt="" src="http://placehold.it/200x150">
<p>2</p>
</div>
</li>
<li class="span3">
<div class="thumbnail" href="#">
<img alt="" src="http://placehold.it/200x150">
<p>3</p>
</div>
</li>
<li class="span3">
<div class="thumbnail" href="#">
<img alt="" src="http://placehold.it/200x150">
<p>4</p>
</div>
</li>
</ul>
</div>
http://jsfiddle.net/baptme/jWcdS/
Notes: This question is inspired by the request asked in a comment on this answer
CSS:
http://jsfiddle.net/baptme/jWcdS/1/
500px wide (2x2)
319px wide (1x4)
Explanations:
Media queries can be used to override twitter bootstrap between 320px and 767px by using
@media (min-width: 320px) and (max-width: 767px)
.row-fluid .thumbnails .span3
has been used over a.span3{ ... }
or.row-fluid .span3{ ... }
for the following reasons:.row-fluid .span3
from bootstrap.css.thumbnails
between.row-fluid
and.span3
will not affect the other.row-fluid .span3
used for the layout.The
width:48.6188%;
andmargin-left: 2.76243%;
correspond the the value given to a.row-fluid .span6
The
float:left;
overrides thefloat:none
The pseudo class
nth-child(2n+1)
has been used withmargin-left: 0;
to remove the left margin on the.row-fluid .thumbnails .span3
ending up on the left side of the page (1 and 3).