Code Snippets

Scroll To Top Using Code Using CSS

Estimated reading: 1 minute 106 views

First, add the button HTML somewhere on your webpage, ideally at the bottom of the page (inside the <body> tag).

<!-- Scroll to Top Button --> <button id="scrollToTopBtn" title="Go to top">↑</button>

You can style the button to make it look good and position it at the bottom-right of the screen. Here’s an example:

/* Scroll to Top Button Styles */ scrollToTopBtn { display: none; /* Hidden by default / position: fixed; / Fixed position on the screen / bottom: 20px; / 20px from the bottom / right: 20px; / 20px from the right / z-index: 99; / Ensures it's on top of other elements / background-color: #333; / Button background color / color: white; / Text color / border: none; / Remove borders / padding: 15px; / Padding inside the button / border-radius: 50%; / Make it a circular button / cursor: pointer; / Pointer cursor on hover / font-size: 18px; / Font size for the arrow */
} scrollToTopBtn:hover {background-color: #555; /* Darker background on hover */
}

Change the colors and padding to your preference.

Leave a Reply

Your email address will not be published. Required fields are marked *

Share this Doc

Scroll To Top Using Code Using CSS

Or copy link

CONTENTS

Join The Party For Fun Updates freebies & Big Discounts!

Add your name
Add your email

JoiN Glamsy Cloud! Free STUNNING Kadence Templates Included!

Start with 5 gorgeous Kadence blocks on us. Love them? Unlock ‘50 FREE FOREVER‘ that’s 50 more free blocks just for choosing any essential tool from our trusted fav stack!

Grab Your Free Templates

Terms Of Use FAQs

Payment FAQs

Order FAQs

Support FAQs

Popular Pre-Sales FAQs

Redesigning FAQs

Adding A Sticky Sidebar Using CSS

If you prefer using custom code to create a sticky sidebar, create or edit a pag

Scroll To Top Using Code Using CSS

First, add the button HTML somewhere on your webpage, ideally at the bottom of t

Choose Your Hosting

Like many people, we started our online journey with one of the big-name hosts—a

Start Here

Glamsy Designs is thrilled to introduce a new documentation system that makes ac

Frequently Asked Questions

Creating Sticky Sidebars Using CSS

We are covering three ways of creating sticky sidebars using Kadence, CSS code,

Chat Icon Close Icon
Review Your Cart
0
Add Coupon Code
Subtotal

 

Subscribe

×
Cancel