Skip to content

Instantly share code, notes, and snippets.

@jesusoterogomez
Created August 18, 2015 08:31
Show Gist options
  • Save jesusoterogomez/f67e5243870106e8ee12 to your computer and use it in GitHub Desktop.
Save jesusoterogomez/f67e5243870106e8ee12 to your computer and use it in GitHub Desktop.
Equal percentage width elements in one row using SASS
/*
Counts elements and applies percentage width to
fit them in one row.
##################################################
# i.e: 4 elements = 25% width; #
# note: Many elements create long CSS output #
##################################################
*/
$min: 1;
$max: 5;
@for $i from $min through $max {
li:first-child:nth-last-child(#{$i}),
li:first-child:nth-last-child(#{$i}) ~ li {
width: 100%/$i
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment