我正在使用reactjs做一个web应用程序。当我向下滚动时,需要更改div的高度,并在滚动时恢复到原始高度。我不确定是否有我需要的CSS解决方案。什么是实现我上面描述的方式。更改滚动div的高度
class InternalGroupsPage extends Component {
constructor() {
super();
}
render() {
return (
<div className="body_clr">
<div className="group_page_header">
This is the div i want to change the height when scrolling
</div>
<div>
Other stuff
</div>
</div>
);
}
}
CSS
.group_page_header {
width: 100%;
height: 220px;
background-color: #0b97c4;
position: fixed;
margin-top: 50px;
z-index: 1;
}
.body_clr {
overflow-y: scroll;
width: 100%;
height: 100%;
position: fixed;
background-color: #eceff1;
}
你的反应组件代码在哪里? –
我只给了html和css,因为我不认为其他代码是必要的。反正我现在更新了 – CraZyDroiD
如果你能为我提供上述代码工作的小提琴,我可以为你做。 基本上你需要切换一个状态变量+ className,当'scrollTop'通过一个特定的点来重新发生。 有道理吗? –