i noticed an issue when using Less with font shorthand
.font(@weight: 300, @size: 22px, @height: 32px) {
font: @weight @size/@height "Helvetica Neue", Arial, "Liberation Sans", FreeSans, sans-serif;
}
the above fails with
this.a.toCSS is not a function
http://localhost/tumblr/modern1/css/style.less on line 1, column 0:
1. @highlight: #cb1e16;
2. @shade1: #cb1e16;
when i split the properties up it works
.font(@weight: 300, @size: 22px, @height: 32px) {
font-weight: @weight;
font-size: @size;
line-height: @height;
font-family: "Yanone Kaffeesatz", "Helvetica Neue", Arial, "Liberation Sans", FreeSans, sans-serif;
}
i think its because of the slash / thats causing the problem, i think since Less can do calculations, eg. 2px + 5 = 7px
its trying to do a divide?
Two of the values in font shorthand are mandatory: font-size and font-family . If either of these is not included, the entire declaration will be ignored.
CSS Font Property To shorten the code, it is also possible to specify all the individual font properties in one property. The font property is a shorthand property for: font-style. font-variant.
5.5 CSS font shorthand The font property regroups (in this particular order): font-style. font-variant. font-weight.
The forward slash is required syntax for separating background position values and background size values. This is to eliminate misinterpretation of the values specified. If you're going to specify both, then background-position has to come first, then the forward slash, then the background-size.
Just ran into this issue, the escape function (for less.js anyway) is: e() Like this
font: @weight @size e('/') @height "Helvetica Neue", Arial, "Liberation Sans", FreeSans, sans-serif;
The forward slash /
character is causing the LESS compiler to divide your font-size by your line-height. You can:
Separate your CSS into non-shorthand, separate rules
font-size: @size; line-height: @height;
Escape some or all of your LESS font shorthand rule. The slash /
itself is the best part to escape. You can use the e, e("/")
escape syntax, or the newer, better documented tilde-quote ~"/"
. You can also use the LESS string interpolation @{}
syntax to insert your variables.
Try this:
font: @weight @size~"/"@height "Helvetica Neue", Arial, "Liberation Sans", FreeSans, sans-serif;
Or this:
font: @weight ~"@{size}/@{height}" "Helvetica Neue", Arial, "Liberation Sans", FreeSans, sans-serif;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With