#Root元素的反应功能组件中的内联样式
我创建了一个React功能组件,在其中附上了一个侦听器以滚动。我已经观察到,此事件侦听器需要使用ID =“ root”的元素附加到此类元素 - document.getElementById(“ root”)
。当前,我有一个分开的CSS文件,可以将样式应用于我的组件专门为卷轴。 CSS样式表有一个单一类#root
我提供growflow-y:scroll
,以便滚动正确地发生。 但是现在,我希望在我的反应功能组件中获得这种样式。怎么办?
I have created a React functional component where I have attached an event listener for scrolling. I have observed that this event listener needs to be attached to the element with ID = "root" i.e something of this sort - document.getElementById("root")
. Currently, I have a seperate CSS file to apply the styling to my component specifically for the scrollbar. The CSS stylesheet has a single class #root
where I provide overflow-y: scroll
, so that scrolling happens properly.
But now, I wish to get this styling within my React functional component. How can this be done ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论