Skip to content

Use visibility:hidden instead of display:none to preserve layout. #18

@ruisoftware

Description

@ruisoftware

When you do $(this).css('display','none'); the this element disappears and any static or relative elements located in the DOM after this, move up and occupy the area once used by the this element. They move up, because what display:none does is hiding the element AND removing the layout space occupied by it.

However, in your code you show and hide the element so fast, that produces no noticeable flickering. But the most important thing: The elementFromPoint() might in fact not read the element underneath, but the sibling element that got just moved up.

You should use $(this).css('visibility','hidden'); instead. It also hides the this element, but maintains the space there, causing no layout changes in the elements that follow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions