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

added a back to top button #131

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
27 changes: 26 additions & 1 deletion assets/css/styles.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
/*===== GOOGLE FONTS =====*/

@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap");

/*back to top button*/
#myBtn {
display: none; /* Hidden by default */
position: fixed; /* Fixed/sticky position */
bottom: 20px; /* Place the button at the bottom of the page */
right: 30px; /* Place the button 30px from the right */
z-index: 99; /* Make sure it does not overlap */
border: none; /* Remove borders */
outline: none; /* Remove outline */
background-color: black; /* Set a background color */
color: white; /* Text color */
cursor: pointer; /* Add a mouse pointer on hover */
padding: 15px; /* Some padding */
border-radius: 10px; /* Rounded corners */
font-size: 18px; /* Increase font size */
}

#myBtn:hover {
background-color: #555;
font-size: 20px; /* Add a dark-grey background on hover */
}
/*===== VARIABLES CSS =====*/


:root {
--header-height: 3rem;
--max-section-width: 64rem;
Expand Down Expand Up @@ -172,6 +193,7 @@ img {
.l-header,
.home {
background-color: var(--new-black-bg) ;
background-image:url(/SurPathHub.github.io/img/wallpapersden.com_programming-coding-language_1920x1080.jpg);
}


Expand Down Expand Up @@ -222,6 +244,7 @@ img {
.nav__link {
color: var(--light-dark);
font-weight: 100;
background-color: black;
}

.nav__link:hover {
Expand Down Expand Up @@ -384,6 +407,7 @@ img {
line-height: 1.1;
margin: 1.2rem 0rem 1rem 0rem;
z-index: 1;
background-color: black;
}

.home__description {
Expand All @@ -396,6 +420,7 @@ img {
font-size: 20px;
height: auto;
margin: auto;
background-color: black;
}

.console {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
</head>

<body>
<!--BACK TO TOP BUTTON-->
<button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
<!--===== HEADER =====-->
<header class="l-header">
<nav class="nav bd-grid">
Expand Down Expand Up @@ -812,6 +814,27 @@ <h2>Location</h2>

<!-- end of animation -->

<script>
let mybutton = document.getElementById("myBtn");

// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};

function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}

// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}
</script>

<!--===== SCROLL JS =====-->
<script src="https://unpkg.com/scrollreveal"></script>

Expand Down