5
I am creating a dynamic grid system using Sass and Gulp-Sass to compile.
I have this code:
$col-margin: 15px
.row
width: 100%
max-width: 1170px
margin: 0 auto
display: flex
flex-wrap: wrap
// cols
=col($cols)
width: calc(((100% * $cols) /12) - ($col-margin * 2))
margin: $col-margin
box-sizing: border-box
In other words, the margin is 15px. When compiling through the terminal, using Gulp-Sass I have this error:
[20:22:31] Starting 'sass'...
[20:22:31] Starting 'watch'...
[20:22:31] Finished 'watch' after 31 ms
Error in plugin 'sass'
Message:
assets\gs.sass
Error: Incompatible units: 'px' and '%'.
on line 10 of assets/gs.sass
>> width: ((100% * $cols) /12) - ($col-margin * 2);
-----------^
[20:22:31] Finished 'sass' after 95 ms
[20:22:31] Starting 'default'...
[20:22:31] Finished 'default' after 20 μs
Did not resolve it pops the formula straight into . css:
.col-10 {
 width: calc(((100% * $cols) / 12) - ($margin-col * 2));
 box-sizing: border-box;
 background: red;
}
– Fabricciomb
width: #{Calc((#{(100% * $cols)} / 12) - #{($margin-col * 2)})}... did not remember this possibility helped much. It is solved.
– Fabricciomb