Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorNarven
    • CommentTimeNov 4th 2006 edited
     permalink
    Hi, everybody;

    I've been working on some code... and i've found out that the method getPropertyValue when aplied to a mesure always returns in PX, even if in the stylesheet the value was defined in EM.

    is this normal? is a bug? is there any way to retrieve the actual value???? or we need to convert it???

    thanks
    •  
      CommentAuthorJohnRiv
    • CommentTimeNov 4th 2006
     permalink
    Yes that is normal, as described in the CSS2 spec section on Computed values:

    Relative values, on the other hand, must be transformed into computed values: percentages must be multiplied by a reference value (each property defines which value that is), values with relative units (em, ex, px) must be made absolute by multiplying with the appropriate font or pixel size, 'auto' values must be computed by the formulas given with each property, certain keywords ('smaller', 'bolder', 'inherit') must be replaced according to their definitions.


    Although I believe the mention of "px" as a relative unit is incorrect.

    If you set the style inline or with javascript, then you could use object.style.styleProperty to get the exact value in the units you specified. Otherwise, you will have to covert the px value to the relative value you want. If you write a script to accomplish that, please share it with us.
    • CommentAuthorNarven
    • CommentTimeNov 4th 2006 edited
     permalink
    thanks, but i dont seem to find info on object.style.styleProperty :|



    if anyone needs to convert px to em, i usually use this:
    http://riddle.pl/emcalc/
    •  
      CommentAuthorJohnRiv
    • CommentTimeNov 4th 2006
     permalink
    thanks for the px to em converter link

    for "object.style.styleProperty", i meant "object" to be the DOM object and "styleProperty" to be the style property you want to access. So an example would be something like:

    document.getElementById("myDiv").style.width
    • CommentAuthorNarven
    • CommentTimeNov 5th 2006
     permalink
    :) thanks
Add your comments
    Username Password
  • Format comments as (Help)