The actual scroll code is fine. The reason it's not working in the Angular 8 version is that you're scrolling on the page, not on the div
. The difference between the two is that the working example has a fixed height with overflow: scroll
whereas the non-working example has the div
taking up its entire height.
To get it to work, you can simply add the following css to the .scrolling-guy
div:
height: 500px;
overflow-y: scroll;
Working example
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…