sass - Multiple SCSS equations to work out width minus margin -



sass - Multiple SCSS equations to work out width minus margin -

i have mixin splits items of users choosing inline-block grid. users can specify how many in row, gutter , kid element target.

this works fine , illustration below:

original - scss

@mixin list-grid($per-row, $spacing, $selector){ margin: 0 em(-$spacing/2); @include clearfix; //negate display-inline biatch letter-spacing: -0.31em; > #{$selector} { width: 100% / $per-row; font-size: 16px; position: relative; padding: 0 em($spacing/2) em($spacing) em($spacing/2); display: inline-block; vertical-align: top; letter-spacing: 0; background-clip: content-box; } }

my question is.. when seek , utilize margin need rework calculations worked because padding not accounted when working out widths, whereas margin need adjust widths business relationship chosen margin.

i'm not sure how best approach this. help appreciated.

new effort - scss

@mixin list-grid($per-row, $spacing, $selector){ margin: 0 em(-$spacing/2); @include clearfix; //negate display-inline biatch letter-spacing: -0.31em; > #{$selector} { /* not sure here */ width: 100% / $per-row -$spacing; font-size: 16px; position: relative; margin: 0 em($spacing/2) em($spacing) em($spacing/2); display: inline-block; vertical-align: top; letter-spacing: 0; background-clip: content-box; } }

the latest effort ends width of 8% if row of 3, 25 gutter. math must way off.

working example

sass

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -