Skip to content

No reliable way to determine if a CSS property is "auto" #16

Open
@gnarf

Description

@gnarf

As the maintainer of an animation / effects library, this issue has been a thorn in my side multiple times. Trying to determine if an element is positioned using left, top or right, bottom or some combination of all of them is currently impossible to do in a cross browser way. The "Computed Style" of right and bottom in webkit will return auto but FF spoils the day by returning an actual px value (which by my interpretation is actually the correct value to return).

After animating elements, my code must either assume that the element was positioned left and top since there is no way to determine what the initial positioning actually was, or accept some sort of configuration parameter to tell it which to use. This means that after running my effect code on your arbitrary div that was positioned using right and bottom it will no longer be positioned relative to the bottom right as its relative container resizes.

The issue of knowing if a CSS property is auto probably has more uses than just left and top. I could see width and height also being useful to know if it is auto or specifically set.

Specific Issues

  • Makes it impossible to detect if an element is positioned with right and bottom

Specific Suggestions

  • isCSSAuto( property ) - Some method (be it on the computed style object, or somewhere else) could be provided to determine if a style property is auto before computation.
  • right and bottom shouldn't return auto on a computed style object.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions