JSFiddle - React, Tailwind, and code Playground
HTML
<button onclick="scrollElt(test)">
Click pour descendre
</button>
<p>
Toto 1
</p>
<p>
Toto 2
</p>
<div id="test">
Arrive ici
</div>
<p>
Titi 1
</p>
<p>
Titi 2
</p>
<button onclick="scrollElt(test)">
Click pour monter
</button>
CSS
p{
height:500px;
background:red
}
div{
height:800px;
background:yellow;
}
JavaScript
function scrollElt(id){
id.scrollIntoView({ block: "end"});
window.scrollBy({ top: 30 -id.clientHeight });
}