A Pen by Anthony Lukes on CodePen.
Created
April 3, 2014 14:58
-
-
Save anthonyLukes/9955923 to your computer and use it in GitHub Desktop.
A Pen by Anthony Lukes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<ul class="blocks blocks_2up"> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
</ul> | |
<br /> | |
<ul class="blocks blocks_3up"> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
</ul> | |
<br /> | |
<ul class="blocks blocks_4up"> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
<li>item</li> | |
</ul> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import "compass"; | |
$MARGIN: 10%; | |
$TRUE_WIDTH: 100% / (100% + $MARGIN); | |
@mixin blockWidth($numOfCols) { | |
width: (1/$numOfCols * 100%) - ($MARGIN * $TRUE_WIDTH); | |
} | |
.container { | |
width: 800px; | |
background-color: blue; | |
margin: auto; | |
} | |
.blocks { | |
font-size: 0; | |
margin-left: -$MARGIN; | |
} | |
.blocks > * { | |
display: inline-block; | |
font-size: 16px; | |
background-color: green; | |
margin-left: percentage(1 - $TRUE_WIDTH); | |
} | |
.blocks_2up > * { | |
@include blockWidth(2); | |
} | |
.blocks_3up > * { | |
@include blockWidth(3); | |
} | |
.blocks_4up > * { | |
@include blockWidth(4); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment