reactjs를 사용하여 웹 응용 프로그램을 만들고 있습니다. 그리고 스크롤 할 때 div의 높이를 변경해야하고 스크롤 할 때 원래 높이로 복원해야합니다. 내가 필요한 것에 CSS 전용 솔루션이 있는지 확실하지 않습니다. 위에 설명한 내용을 달성하는 방법은 무엇입니까? jQuery를 사용하여스크롤 할 때 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
위의 코드가 작동하는 바이올린을 제공 할 수 있다면, 나는 그것을 할 수있다. 기본적으로'scrollTop'이 rerender가 발생하기 위해 특정 지점을 지나갈 때 상태 변수 + className을 토글해야합니다. 의미가 있습니까? –