Compare HTML elements by actual z-index

后端 未结 3 1117
感情败类
感情败类 2020-12-17 17:58

Given two abitrary HTML elements A and B in the same document, how can I find out which one is \"closer\" to the user (i.e. if they overlap, which one is obscuring the other

3条回答
  •  不思量自难忘°
    2020-12-17 19:00

    You could get the elements' dimensions and offsets, and then use document.elementFromPoint() to determine which one is the element rendered on top.

提交回复
热议问题