This question already has an answer here:
- Calculate a percent with SCSS/SASS 2 answers
I have a map that is 930px x 530px. I want to use a mixin to convert the lat/long coords to top/left percentage values inside the box.
This is what i have so far...
@mixin latLong ($lat, $long) {
left: (($long + 180) * (930/360)) + %;
top: (($lat + 90) * (530/180)) + %;
}
I use it like this...
&.m1 {@include latLong(-33.94628333, 151.2157139);}
This is spitting out a value, but it's in quotes, so it's invalid to css. What am I doing wrong? Thanks.
You want to use multiplication to apply a unit, rather than concatenation:
Try using the native SASS helper method for percentages: http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html#percentage-instance_method.