动态的计算弹框距离外部元素的位置,即获取元素的offsetLeft、offsetTop、offsetWidth、offsetHeight,如果弹框的宽度(offsetWidth)+距离左边的距离(offsetLeft)大于父元素的宽度,则判断为超出外部元素范围,需要动态改变弹框距离边框的位置

下面是对offsetTop,offsetHeight,clientHeight,scrollHeight,scrollTop图解

offsetTop,offsetHeight,clientHeight图解

 

对元素的布局有限制,不能使用display:none的方式隐藏,可以使用opacity:0或者visibility: hidden隐藏元素,因为display:none方式不能获取到元素的高度,宽度等

相关文章:

  • 2021-04-07
  • 2022-01-14
  • 2021-11-14
  • 2022-12-23
  • 2021-04-16
猜你喜欢
  • 2022-02-19
  • 2021-11-29
  • 2021-09-29
  • 2021-11-21
相关资源
相似解决方案