W3C home > Mailing lists > Public > www-style@w3.org > February 2011

Re: CSS Variables

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 8 Feb 2011 10:31:23 -0800
Message-ID: <AANLkTimFmUoqeM1pN+608LDKd7HMPTTtqPmCYBygAWRQ@mail.gmail.com>
To: "Linss, Peter" <peter.linss@hp.com>
Cc: "L. David Baron" <dbaron@dbaron.org>, www-style list <www-style@w3.org>
On Tue, Feb 8, 2011 at 10:18 AM, Linss, Peter <peter.linss@hp.com> wrote:
> What about:
> @var $a px;             p { width: 100$a; }
> or (I don't see how to do it with the '$' syntax):
> @var b 200;             p { width: var(b)px; }

Those both require character-level variables to work as written, which are evil.

They can be accomplished in a hacky way, if you really need it:

@var $a 1px;
p { width: calc( 100 * $a ); }

@var $b 200;
p { width: calc( $b * 1px ); }

Well-defined unit algebra is much better than hacky character macros.  ^_^

~TJ
Received on Tuesday, 8 February 2011 18:32:16 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:37 GMT