Looking to create a Pure CSS Scroll to top, I attempted it but struggled with making it clickable like in JavaScript. Here is the CSS code I tried:
body {
height: 99999999999999999999999999999999999px;
position: relative;
}
button {
color: white;
width: 30px;
text-decoration: none;
height: 30px;
text-align: center;
position: fixed;
left: 95%;
top: 92%;
cursor: pointer;
line-height: 20px;
background-color: red;
}
HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="study2.css" />
</head>
<body>
<span class="scroll"><button >Up</button></span>
<div>One</div>
</body>
</html>