Skip to content

Instantly share code, notes, and snippets.

@Swimburger
Last active June 15, 2017 08:14
Show Gist options
  • Save Swimburger/8bc22abcf55f891ed44b1a39546d9f34 to your computer and use it in GitHub Desktop.
Save Swimburger/8bc22abcf55f891ed44b1a39546d9f34 to your computer and use it in GitHub Desktop.
calculate grid item width
function getWidth(width, spacing, amountOfColumns){
return (width - (spacing * (amountOfColumns - 1))) / amountOfColumns;
}
console.log(getWidth(921, 10, 3));
console.log(getWidth(921, 10, 2));
console.log(getWidth(921, 10, 1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment