如何在JavaScript中确定水平滚动条的高度或垂直滚动条的宽度?
发布于 2014-04-11 00:40:01
detectScrollbarWidthHeight: function() {
var div = document.createElement("div");
div.style.overflow = "scroll";
div.style.visibility = "hidden";
div.style.position = 'absolute';
div.style.width = '100px';
div.style.height = '100px';
document.body.appendChild(div);
return {
width: div.offsetWidth - div.clientWidth,
height: div.offsetHeight - div.clientHeight
};
},已在Chrome、FF、IE8、IE11中测试。
https://stackoverflow.com/questions/986937
复制相似问题