This is the first time I'mn building a site using LESS and encountered a problem best described by the code below:
@section-row-padding-size-xs: 30px;
@section-row-padding-size-sm: 50px;
@section-row-padding-size-md: 100px;
@section-row-padding-size-lg: 140px;
.section-row-padding( @size ) {
@padding-size: ~"@{section-row-padding-size-@{size}}";
.section-row {
padding: @padding-size 0;
&.quarter-padding-top {
padding-top: @padding-size * 0.25;
}
&.quarter-padding-bottom {
padding-bottom: @padding-size * 0.25;
}
&.half-padding-top {
padding-top: @padding-size * 0.5;
}
&.half-padding-bottom {
padding-bottom: @padding-size * 0.5;
}
&.three-quarters-padding-top {
padding-top: @padding-size * 0.75;
}
&.three-quarters-padding-bottom {
padding-bottom: @padding-size * 0.75;
}
}
}
All this code does is outputting the right padding sizes for use in media queries.
Any call to .section-row-padding()
either with lg, md, sm and xs argument should output the appropriate padding sizes.
The problem is caused by the @padding-size not intepreted as a px unit but rather as a string. I've tried several interpolation methods, but none of them works.
isnumber( @padding-size )
outputs false and istring( @padding-size )
outputs true.
@padding-size + 0px
does not work either, it says Operation on an invalid type.
Is there anything that I missed?
Thanks for your time and answer!