So I'm trying to scroll to the top of the screen when the user submits a form. The answers on stacked overflow don't seem to work for me.
here's my code:
handleClick (evt) {
evt.preventDefault();
this.calculateScore();
this.setState({submittingQuiz: true});
// let myPage = document.querySelector('body');
// myPage.scrollTo(0,0); Couldn't get this way to work either
window.scrollTo({top: 0, behavior: 'smooth'})
}
Any thoughts on how to fix this problem. I have some styling I think may be messing with it..
html {
background-image: url('./tupac.jpeg');
background-position-y: -580px;
background-repeat: no-repeat;
background-size: cover;
overflow: hidden;
}
Anyone got a clue?
This probably happens because the body has a height: 100vh; or some main container of the application has the same height: 100vh;
Try remove height: 100vh; on body and the main container of the application and test it again.