W3C home > Mailing lists > Public > www-style@w3.org > September 2010

Re: [css3-values] Suggestion: Allowing attr() in calc()

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 1 Sep 2010 12:30:32 -0700
Message-ID: <AANLkTinge2AdCf-NfRfy7tdhPBZcjU=BzWw3PTB5t87F@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: Lea Verou <leaverou@gmail.com>, www-style@w3.org
On Wed, Sep 1, 2010 at 11:42 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 9/1/10 2:41 PM, Boris Zbarsky wrote:
>>
>> On 9/1/10 2:39 PM, Lea Verou wrote:
>>>
>>>> I must be missing something here. Say I have this rule:
>>>>
>>>> * { width: calc(attr(border) * 10px); }
>>>>
>>>> and this HTML document:
>>>>
>>>> <table border=1"></table>
>>>> <div border="1"></div>
>>>>
>>>> What are the computed widths of the div and table, and why?
>>>>
>>>> -Boris
>>>
>>> Same as:
>>> * { width: calc(1 * 10px); }
>>>
>>> Which if my understanding is correct ends up being equivalent to:
>>> * { width: 10px; }
>>>
>>> Am I missing something?
>>
>> The "width" attribute on <div> is not an integer attribute. It's just a
>> string attribute.
>
> Er, of course I meant the "border" attribute.  But the point is that the
> type of an attribute depends on the node.

Right, that's what the 'type' argument to attr() is for.  The example
as you wrote it won't work.  You could instead write it as:

* { width: calc( attr(border,integer) * 10px ); }

(This would also then default to 0, though you can override that.)

~TJ
Received on Wednesday, 1 September 2010 19:31:25 GMT

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