只是一个工作正常的测试。
#parent{
height: 100%;
width: 100%;
overflow: hidden;
}
#child{
width: 100%;
height: 100%;
overflow-y: scroll;
padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
}
JavaScript:
因为,不同浏览器的滚动条宽度不同,最好用JavaScript处理它。如果你做Element.offsetWidth – Element.clientWidth,将会显示确切的滚动条宽度。
要么
使用位置:绝对,
#parent{
height: 100%;
width: 100%;
overflow: hidden;
position: relative;
}
#child{
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: -17px; /* Increase/Decrease this value for cross-browser compatibility */
overflow-y: scroll;
}
信息:
基于这个答案,我创建了一个simple scroll plugin.我希望这将帮助某人。