Trouble outputting font property using less variab

2019-08-20 09:08发布

I'm using twitter bootstrap with less and I have the following:

@serifFontFamily: 'Droid Serif', "Georgia", Times, serif;
@baseFontSize: 100%/1.5;

font: @baseFontSize @serfiFontFamily;

it produces:

font: 66.666666667% 'Droid Serif', "Georgia", Times, serif

but I want to output this:

font: 100%/1.5 'Droid Serif', "Georgia", Times, serif

Any tips?

2条回答
够拽才男人
2楼-- · 2019-08-20 09:31

You can use

@baseFontSize: ~"100%/1.5";

and less will interpret it as a string and not as an expression.

查看更多
冷血范
3楼-- · 2019-08-20 09:37

I had decomposed the property font in 3 properties:

font-size: @baseFontSize;
font-family: @baseFontFamily;
line-height: @baseLineHeight;

and my variables:

@baseFontSize:          100%;
@baseFontFamily:        'Droid Serif', "Georgia", Times, serif;
@baseLineHeight:        1.5;

than it works properly!

查看更多
登录 后发表回答