java攻克轮播图之深度了解偏移量

偏移量

  • offsetParent用于获取定位的父级元素

  • offsetParent和parentNode的区别

    var box = document.getElementById(‘box’);
    console.log(box.offsetParent);
    console.log(box.offsetLeft);
    console.log(box.offsetTop);
    console.log(box.offsetWidth);
    console.log(box.offsetHeight);

客户区大小

var box = document.getElementById('box');
console.log(box.clientLeft);
console.log(box.clientTop);
console.log(box.clientWidth);
console.log(box.clientHeight);

滚动偏移

var box = document.getElementById('box');
console.log(box.scrollLeft)
console.log(box.scrollTop)
console.log(box.scrollWidth)
console.log(box.scrollHeight)

结语:生命诚可贵,爱情价更高,若为代码故,两者皆可抛!

ps:本文纯属原创,抄袭必究.

猜你喜欢

转载自blog.csdn.net/weixin_44387879/article/details/86439825