offsetTop,offsetHeight,clientHeight图解

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

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

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

猜你喜欢

转载自blog.csdn.net/weixin_42776027/article/details/88568306