<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scroll to Top Button</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
background-color: #f0f2f5;
height: 2000px; /* For demonstration */
}
.scroll-top-button {
position: fixed;
bottom: 20px;
right: 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 50%;
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
font-size: 1.5em;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
transition: background-color 0.3s;
}
.scroll-top-button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<button class="scroll-top-button" onclick="scrollToTop()">⇧</button>
<script>
function scrollToTop() {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
</script>
</body>
</html>