我只想偏移红色框的底部空间,当我滚动正文时,滚动红色框将某些部分隐藏到正文滚动中,然后我要单击一个按钮以获取红色框的底部偏移{{3 }}
//want offset bottom of box after some scroll of body scroll
.divHasScroll {
height: 200px;
width: 350px;
background: red;
overflow: auto
}
<div class="divHasScroll">
<p> text in box</p>
<p> text in box</p>
<p> text in box</p>
<p> text in box</p>
<p> text in box</p>
<p> text in box</p>
<p> text in box</p>
<p> text in box</p>
<p> text in box</p>
<p> text in box</p>
<p> text in box</p>
</div>
<p> text in window scrolling section</p>
<p> text in window scrolling section</p>
<p> text in window scrolling section</p>
<p> text in window scrolling section</p>
<p> text in window scrolling section</p>
<p> text in window scrolling section</p>
<p> text in window scrolling section</p>
<p> text in window scrolling section</p>
<p> text in window scrolling section</p>
<p> text in window scrolling section</p>
<p> text in window scrolling section</p>
<p> text in window scrolling section</p>
<p> text in window scrolling section</p>
<p> text in window scrolling section</p>
答案 0 :(得分:0)
如果您的容器是主体,则可以通过此计算获得偏移量
alert($('body').height() - $('.divHasScroll').height());
您需要容器的高度-可滚动div的高度。
偏移属性仅适用于顶部或左侧,在这种情况下将不为您服务。
希望这会有所帮助。