Skip to content

Instantly share code, notes, and snippets.

@daphotron
Last active August 29, 2015 14:05
Show Gist options
  • Save daphotron/84e9209e78136af33405 to your computer and use it in GitHub Desktop.
Save daphotron/84e9209e78136af33405 to your computer and use it in GitHub Desktop.
Responsive 3 column
<ul>
<li class="span3">
Text
</li>
<li class="span3">
Text
</li>
<li class="span3">
Text
</li>
</ul>
$em-base: 16px;
$bp-widest: 900px/$em-base + 0em;
$bp-wide: 700px/$em-base + 0em;
.span3 {
display: block;
@media (min-width: $bp-wide) {
// 2 col
float: left;
margin-right: 2%;
width: 48%;
}
@media (min-width: $bp-widest) {
// 3 col
width: 32%;
}
}
// first of 2
.span3:nth-child(2n+1) {
@media (min-width: $bp-wide) and (max-width: $bp-widest) {
clear: left;
}
}
// last of 2
.span3:nth-child(2n) {
@media (min-width: $bp-wide) and (max-width: $bp-widest) {
margin-right: 0;
}
}
// first of 3
.span3:nth-child(3n+1) {
@media (min-width: $bp-widest) {
clear: left;
}
}
// last of 3
.span3:nth-child(3n) {
@media (min-width: $bp-widest) {
margin-right: 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment