Re: [cssom] CSS Value API

On Apr 7, 2010, at 9:02 AM, Anne van Kesteren wrote:

> On Wed, 07 Apr 2010 17:50:45 +0200, François REMY <fremycompany_pub@yahoo.fr> wrote:
>> To be logical, we should modify margin-top to calc(15%+1px).
>> Or is that no more allowed by CSS-Values?
> 
> For some definition of logical that is certainly an interesting idea. It would however completely break the getter/setter symmetry of "px". I personally value that a little higher.

Could you explain this further? Wouldn't you also get the px value of something that had a percentage style, as though you were using calc()?

Or, put differently, when setting the margin-top in this example, I would hope for this to  convert the percentage to px, add one px, then convert back to percentage (so that you are increasing the margin by one pixel based on the current width of the containing block, but not changing the continuing relationship between the margin and the containing block). If you actually wanted to go further and change the margin-top to a calc value, you would instead do something like this:

style.margin.m.top.calc.px++

Then, if the margin-top in the example would become "calc(15%+1px)", and in a different example where margin-top already had a calc value, then it would become "calc((<previous-formula>)+1px)". If you wanted to convert a value to calc when getting it (for whatever strange reason), you could do that like this:

style.margin.m.top.calc // --> "calc(15%)" in the first example

Received on Thursday, 22 April 2010 15:57:01 UTC