Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LESS CSS - Unable to divide two pixel units and return a unit-less value

Tags:

css

web

less

I'd like to (temporarily) remove the units of my variables @baseLineHeight and @baseFontSize, so that I can divide them to get a relative line-height. This is what I've tried:

@baseFontSize: 12px;
@baseLineHeight: 18px;
font: @baseFontSize~"/"@baseLineHeight/@baseFontSize sans-serif;

Generates the following error:

Object #<Object> has no method 'toCSS' (Less::ParseError)

Preferred output:

font: 12px/1.5 sans-serif;
like image 739
Vitamin Avatar asked Feb 21 '12 18:02

Vitamin


1 Answers

Meanwhile there seems to be a function for that: http://lesscss.org/functions/#misc-functions-unit

Here the code from the comment, just for completeness. (thanks to cfx).

font: @baseFontSize~"/"unit(@baseLineHeight/@baseFontSize) sans-serif;
like image 155
Niklas Peter Avatar answered Sep 18 '22 03:09

Niklas Peter