I know that here on the site there are a lot of Soft Scroll and Button issues for "back to top" ( back to top
), but they all involve JavaScript or jQuery, but this não
is my goal.
I would like to make or know if it is now possible to make a smooth scroll with CSS only. method on a button of type Voltar para o Topo
?
Just the button that sends me back to the top I got, now I'd like to put a smooth page scrolling behavior back to the top.
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
section {
height: 300vh;
background-image: linear-gradient(red, blue);
}
.btn {
display: flex;
justify-content: center;
align-items: center;
position: fixed;
bottom: 10px;
right: 10px;
width: 50px;
height: 50px;
background-color: #000;
text-decoration: none;
}
.btn::after {
content: "↑";
font-size: 32px;
font-weight: bold;
color: aliceblue;
transition: margin-top 250ms;
}
.btn:hover::after {
margin-top:-8px;
}
<section></section>
<a href="#" class="btn"></a>