scrollLeft生效条件:
1.首先元素内容的宽度超过元素的宽度;
2.其次元素设置了overflow属性,并且overflow属性值不能为visiable
// An highlighted block
.father{
width: 200px;
height: 200px;
//注意这里overflow属性写在外层div上
overflow:hidden;
}
.son{
width: 2000px;
height: 200px;
}
<div class="father">
<div class="son"></div>
</div>
//son表示外层div的‘内容’的宽度:2000px
//father表示外层div的宽度:200px
//设置scrollLeft属性也是在外层div上设置
father.scrollLeft += 200;
offsetWidth: 包含content+padding+border宽度
clientWidth:content+padding宽度
scrollWidth:content+padding+溢出的部分宽度
offsetLeft:元素的左外边框至包含元素的左内边框之间的像素距离