I decided to use the nth-child selector to remove the field on certain .span. So my final solution was like:
One span column for 320px to 979px
Two span columns for 980px to 1409px
Three column spans for 1409px and above
@media (min-width: 320px) and (max-width:979px) { .row-fluid .span4 {width:100%} .row-fluid .span4 {margin-left:0;} } @media (min-width: 980px) and (max-width:1409px) { .row-fluid .span4 {width:48.717948718%;} .row-fluid .span4:nth-child(2n+3) {margin-left:0;} } @media (min-width: 1410px) { .main .span4:nth-child(3n+4) {margin-left:0;} }
For IE7 and 8, I set the width of each span to 48.717948718% (so there are two lines) in css - specifically for these versions, using the html5 bolierplate.oldie html class. Then I used Modernizr and a custom test for nthchild found at https://gist.github.com/1333330 and removed the field for each even range if the browser does not support the nth-child selector.
if (!Modernizr.nthchildn) { $('.span4:even').addClass('margless'); }
source share