Resolving the issues and creating a subtle fade-in effect for the footer positioned at the bottom of the webpage with

I'm attempting to keep my footer fixed at the bottom of the page and have it fade in when scrolling to the very end. However, currently, it remains at the top of the page.

Despite trying the code below, I can't seem to get it to display with a "slowReveal" effect...

I've placed my footer at the bottom of my pages, adjusted the footer as per your instructions, and included my CSS file.

<!doctype html>
<html lang="en">
    <head>
        <!-- Required meta tags -->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <!-- Bootstrap CSS -->
        <link rel="stylesheet" href="css/bootstrap.css">
        <link rel="stylesheet" href="css/tarraps_stylesheet.css">
        <link rel="stylesheet" href="js/bootstrap.js">
        <link rel="stylesheet" href="js/jquery-3.4.0.min.js">
        <!-- Bootstrap for Glyphicons -->       

        <!-- jquery js -->
        <script src="https://code.jquery.com/jquery-3.3.1.slim.js"></script>    
        
<script>

$(document).ready(function() {

  function isScrolledIntoView(elem) {
    var docViewTop = $(window).scrollTop();
    var docViewBottom = docViewTop + $(window).height();
    var elemTop = $(elem).offset().top;
    return ((elemTop <= docViewBottom) && (elemTop >= docViewTop));
  }

  function checkScrolling() {
    if (isScrolledIntoView($('.myFooterClass')) == true) {
      if ($('.myFooterClass').hasClass('slowReveal')) { /**/ } else {
        $('.myFooterClass').addClass('slowReveal');
      }
    } else {
      if ($('.myFooterClass').hasClass('slowReveal')) {
        $('.myFooterClass').removeClass('slowReveal');
      }
    }
  }

  window.onscroll = function() {
    checkScrolling();
  }
  window.onresize = function() {
    checkScrolling();
  }
})

</script>


    <body>
    
                <div class="row">
                
                <div class="col-md-12 mb-4">
            
                    <footer class="page-footer grey text-center text-md-left mt-0">

                        <div class="container-fluid">
                            <div class="row">

                                <div class="col-md-6">
                                    <h5 class="title mb-3">Footer</h5>
                                    <p>This page was created as part of the programming workshop.</p>
                                </div>

                                <div class="col-md-6">
                                    <h5 class="title mb-3">Links</h5>
                                    <ul>
                                        <li><a href="https://www.h-da.de/">Go to Hochschule Darmstadt website</a></li>
                                    </ul>
                                </div>
                                
                            </div>
                        </div>
                        

                        <div class="footer-copyright">
                            <div class="container-fluid">
                                © 2019 Copyright: <a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7d101c090915141c">[email protected]</a>"> Matthias Weihrauch </a>

                            </div>
                        </div>
                        
                    </footer>
                    
            
                </div>
                
            
            </div>
    
    </body>
    </head>

https://i.sstatic.net/FnKdn.png

Currently, the footer is only at the bottom of the content and not sticking to the bottom of the page...

Answer №1

  • The footer is positioned at the bottom of the page to ensure it remains visible at all times
  • We use a function to determine if the footer is in view, and if so, we apply the class slowReveal to initiate an opacity animation
  • The slowReveal class triggers a smooth transition of the footer's opacity from faded to fully visible

See the working code snippet below:

$(document).ready(function() {

  function isScrolledIntoView(elem) {
    var docViewTop = $(window).scrollTop();
    var docViewBottom = docViewTop + $(window).height();
    var elemTop = $(elem).offset().top;
    return ((elemTop <= docViewBottom) && (elemTop >= docViewTop));
  }

  function checkScrolling() {
    if (isScrolledIntoView($('.myFooterClass')) == true) {
      if ($('.myFooterClass').hasClass('slowReveal')) { /**/ } else {
        $('.myFooterClass').addClass('slowReveal');
      }
    } else {
      if ($('.myFooterClass').hasClass('slowReveal')) {
        $('.myFooterClass').removeClass('slowReveal');
      }
    }
  }

  window.onscroll = function() {
    checkScrolling();
  }
  window.onresize = function() {
    checkScrolling();
  }
})
.ContentArea {
  height: 2000px;
}

.ContentAreaContent {
  text-align: center;
  padding: 20% 5%;
  font-size: 4em;
}

footer {
  background: lightblue;
}

.slowReveal {
  animation: slowlyReveal 2s ease-in-out;
}

@keyframes slowlyReveal {
  from {
    opacity: 0.05;
  }
  to {
    opacity: 1;
  }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

<div class="container-fluid">
  <div class="row">
    <div class="col-12 ContentArea">
      <div class='ContentAreaContent'>
        this is just content area... where other elements of your page will show up

      </div>
    </div>

    <div class="col-12">
      <footer class="page-footer grey text-center text-md-left mt-0 myFooterClass">

        <div class="container-fluid">
          <div class="row">
            <div class="col-md-6">
              <h5 class="title mb-3">Footer</h5>
              <p>This page was created as part of a programming workshop.</p>
            </div>
            <div class="col-md-6">
              <h5 class="title mb-3">Links</h5>
              <ul>
                <li><a href="https://www.h-da.de/">Visit Hochschule Darmstadt Website</a></li>
              </ul>
            </div>
          </div>
        </div>
        <div class="footer-copyright">
          <div class="container-fluid">
            © 2019 Copyright: <a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e68b8792928e8f8795c891838f8e948793858ea695929382c88ecb8287c88283">[email protected]</a>"> Matthias Weihrauch </a>

          </div>
        </div>
      </footer>
    </div>
  </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Trouble with CSS in a WordPress theme utilizing a two-column layout

After setting up my wordpress blog (http://raptor.hk), I encountered an issue with aligning the right sidebar correctly. It seems like I have overlooked something in the CSS code. The div responsible for the sidebar has been assigned the name "rightbar". I ...

How to transfer data from local storage to PHP using Ajax

Is there a way to pass values from JavaScript to PHP that are stored in local storage? JavaScript let cartItems = localStorage.getItem("productsInCart"); var jsonString = JSON.stringify(cartItems); $.ajax({ url:"read.php", method: "post", da ...

Challenges with implementing @Html.EditorForModel

Currently, I am developing a web application using asp.net's mvc-5 framework. In this project, I have implemented the following model class: public class Details4 { [HiddenInput(DisplayValue=false)] public string RESOURCENAME { se ...

Using the `display: inline-block` property will generate a horizontal line at the bottom of the

While working on developing a website to showcase the services of a company, I encountered an unexpected issue. When coding another section of the site, a strange bar appeared on my second menu for selecting categories. It's driving me crazy! You can ...

Guideline on extracting private keys from Windows Certificate Manager

I am currently working in a Windows environment setting. Within my organization, we act as our own certificate authority for internally-used https applications. I have obtained a certificate from our system for a private web server I created. While using ...

Enhance and Modify feature using Javascript

I'm facing two issues with my product information form. Firstly, after I submit the data, I want the input fields to be cleared automatically. Secondly, the edit function doesn't seem to work at all. I'm quite stuck on how to resolve these p ...

Using ReactJS to search for and replace strings within an array

A feature of my tool enables users to input a string into a textfield and then checks if any words in the input match with a predetermined array. If the user's string contains a specific name from the array, I aim to replace it with a hyperlink. I&a ...

What is the process ShaderToy uses to load sound files directly into a texture?

I'm attempting to replicate the functionality of shadertoy in passing audio frequency and waveform into a shader using three.js. In this specific example, it appears that IQ is converting audio data into an image which is then utilized as a texture i ...

Eliminating pins from Biostall Google Maps plugin in CodeIgniter

After successfully setting up the Biostall Google Maps for Codeigniter, I am now looking to remove specific markers using ajax. The JavaScript code being executed is as follows: var myLatlng = new google.maps.LatLng(53.236114, 6.496444); var markerOption ...

Having trouble loading a local texture in Three.js while using it as a component in Vue.js

When I run a three.js animation as a component within Vue, it works perfectly fine when loading the texture from an external online resource. However, when I try to run it locally by loading the texture from a local path, it displays black with no error me ...

Discover the underlying data within a nested JSON structure and track back to identify the corresponding values

In the JSON structure provided below, Suppose I have the chapter "number" and section "number". What is the most efficient way to search and trace backwards starting from what I already know, in order to find the "number" of the title within titles and t ...

Is there a way to achieve the same functionality in Javascript without utilizing a for loop?

Is there a way to achieve the same result as this code snippet without utilizing a for loop? Currently unsure about which array method would be appropriate function duplicateElements(x){ var y = []; x.forEach(element =>{ y.push(element ...

React Apollo Error - When using refetchQueries, data does not re-render in one component but does so in another. Surprisingly, it works when the refetchQueries is in the same

Within my application, there is a Main Component that displays a list of todos. Additionally, the Sidebar Component showcases various products as illustrated below ...

Vue and Summernote issue: Model content doesn't display in form when loaded from database

I am having an issue with my form that uses the Summernote wysiwyg editor multiple times. When I fill out the form, everything works correctly - the model is updated, content is displayed, and the data is saved to the database. However, when I try to edit ...

Extend the current main scene by overlaying a similar scene on the side

In my game scene, I have a group of robots that are currently active. What I'm trying to achieve is switching the camera perspective to one of the robots' first person view and displaying it in a small window on the side above the current scene. ...

Issues encountered while trying to update the database using Jquery.Ajax

Currently developing a website and seeking to update a field in a database table upon clicking a specific div. Came across some code example on stack, which can be found here, but for some reason it is not working even though it was accepted. Using C# ASP. ...

Keep things in line with async functions in Node JS

Hello, I am just starting out with NodeJs and I have a question. I am trying to push elements into an array called files based on the order of the urls provided, but it seems like I'm getting a random order instead. Below is the code I've been wo ...

Displaying an image based on the selected dropdown using PHP, AJAX, and JQuery

This requires knowledge of PHP, AJAX, and JQuery. Hopefully, this question is straightforward. I have a dynamic dropdown menu that shows content when an option is selected. The content I want to display is an image. To achieve this, I am working with two ...

Guide to customizing the sorting icon style in Material UI table

I'm looking to enhance the visibility of the sorting icons in a material table even when they are hidden. Currently, the opacity of the icons is set to 0 when not selected or visible. I would like to adjust this opacity to 0.4 so that they remain slig ...

ERROR: The data has reached its end prematurely (data length = 0, requested index = 4). Could this be a corrupted zip file?

Currently, I am developing a WhatsApp bot and storing the chat data in an Excel file using exceljs for further processing. In order to handle responses efficiently, I am utilizing promises to resolve them. Below is the function I have created to read the c ...