Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT #980 Back to Top Button #1075

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
- [Hritik Singhal](https://github.com/hritik1503)
- [Akshit Agrawal](https://github.com/justAkshitAgrawal)
- [Sayantan Choudhury](https://github.com/Sch476)
- [Avdhesh Varshney](https://github.com/Avdhesh-Varshney)

36 changes: 35 additions & 1 deletion commonStyles.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,38 @@ footer {

.md\:hover\:scale-95:hover{
box-shadow: 5px 4px 20px 0px rgba(0,0,0,0.5);
}
}

/* Styling of back to top arrow button */
#toTop {
background-color: white;
position: fixed;
bottom: 16px;
right: 32px;
width: 50px;
height: 50px;
border-radius: 50%;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
font-size: 32px;
color: #093;
text-decoration: none;
/* opacity: 0;
pointer-events: none; */
transition: all 0.4s;
box-shadow: 0px 0px 30px 2px white;
}

#toTop:hover {
box-shadow: 0px 0px 60px 30px #093;
background-color: #093;
color: white;
}

.active {
pointer-events: auto;
opacity: 1;
bottom: 32px;
}
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp"></script>
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>Moksh</title>
<link rel="icon" type="image/x-icon" href="Images/logoBgRemoved.webp" />
<link rel="stylesheet" href="commonStyles.css" />
</head>

<body>
<div id="toTop" class="active">
<i class="fa fa-arrow-up"></i>
</div>
<div class="blogWrapper h-screen overflow-hidden relative">

<!-- Site Menu Links -->
Expand Down
11 changes: 11 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,14 @@ subscribeBtn.onclick = () =>
{
alert( 'It will be functional soon!!' )
}

// Adding functioning of back to top button
const toTop = document.getElementById('toTop');

toTop.addEventListener('click', ()=> {
window.scroll({
top: 0,
left: 0,
behavior: 'smooth'
});
});