-1

我想做一件简单的事情:我有一个两个滚动的网站,当滚动在右侧部分达到最大值时,我想隐藏右侧部分。所以我用

document.onscroll = function() {
if (window.innerHeight + window.scrollY > document.body.offsetHeigh...

但是当卷轴在左侧达到最大值时,右侧部分被隐藏。我能怎么做 ?

有精确问题的代码笔: https ://codepen.io/marie-fran-oise-talbot/pen/LKeqBE

谢谢你

4

1 回答 1

0

不需要js。您必须创建一个固定高度并隐藏溢出的主 div。这是一个工作演示:https ://codepen.io/anon/pen/ydpwNZ

.main{
  overflow:hidden;
  height:300px
}
.txt{
  width: 50%;
  overflow-y:scroll;
  height:100%;
  float:left;
}

.background{
  background-color:  #EAECEE;
  width:30%;
  overflow-y:scroll;
  height:100%;
}
于 2019-06-29T07:25:18.237 回答