Ensure the footer DIV remains at the bottom even after loading AJAX content

I've encountered an issue with the footer DIV not moving to the bottom of the page after new content is added to the above DIV using AJAX. Initially, when the page loads, the footer is at the bottom, but after the AJAX call inserts a lot of content, the footer remains in place and doesn't update itself.

Does anyone know how to resolve this? I am using jQuery to insert the AJAX content after the page has loaded.

I have already attempted using "position:absolute; bottom:0; left:0" on the footer div, but it still doesn't move after the AJAX call.

Thank you in advance!

<body style="width:100%; height:100%;" onload="displayContent()">
    <div id="main" style="width:100%; height:100%;" >
        <div id="header" style="width:100%; height:10%;">
            <div style="width:100%; height:100%;">
                <div  style="display:inline; float:left; width:10%; height:100%;">Logo</div>
                <div  style=" display:inline; float:right; width:90%; height:100%;">Navigation Links</div>
            </div>
        </div>
        <div style="width:100%; height:5%;">
            Navigation links go here
        </div>
        <div id="body" style="width:100%; height:75%;">
            <div id="content" style="display:inline; float:left; width:70%; height:100%;">Main content from AJAX call after page onload goes here</div>
            <div  style="display:inline; float:right; width:30%; height:100%; background:red;">Other stuff here</div>
        </div>
        <div id="footer" style="width:100%; height:10%;">
            FOOTER NEEDS TO UPDATE ITSELF AFTER AJAX CALL
        </div>
    </div>
</body>

Answer №1

The issue arises from the percentage heights assigned to the elements. To fix this, you can either give the #body element an auto height or make it adjust to content changes by using the overflow property.

I do not recommend using inline styles

<body style="width:100%; height:100%;" onload="displayContent()">
    <div id="main" style="width:100%; height:100%;" >
        <div id="header" style="width:100%; height:10%;">
            <div style="width:100%; height:100%;">
                <div  style="display:inline; float:left; width:10%; height:100%;">Logo</div>
                <div  style=" display:inline; float:right; width:90%; height:100%;">Navigation Links</div>
            </div>
        </div>
        <div style="width:100%; height:5%;">
            Navigation links go here
        </div>
        <div id="body" style="width:100%; height:auto; overflow: hidden;">
            <div id="content" style="display:inline; float:left; width:70%; height:100%;">Main content from AJAX call after page onload goes hereMain content from AJAX call after page onload goes hereMain content from AJAX call after page onload goes hereMain content from AJAX call after page onload goes hereMain content from AJAX call after page onload goes hereMain content from AJAX call after page onload goes hereMain content from AJAX call after page onload goes hereMain content from AJAX call after page onload goes hereMain content from AJAX call after page onload goes hereMain content from AJAX call after page onload goes hereMain content from AJAX call after page onload goes hereMain content from AJAX call after page onload goes here</div>
            <div  style="display:inline; float:right; width:30%; height:100%; background:red;">Other stuff here</div>
        </div>
        <div id="footer" style="width:100%; height:10%;">
            FOOTER NEEDS TO UPDATE ITSELF AFTER AJAX CALL
        </div>
    </div>
</body>

Answer №2

By utilizing the CSS properties position: static; and bottom:0;, you have the ability to consistently keep your element anchored at the bottom of the screen. To ensure that your footer does not overlap with other content, consider adding bottom padding to your content-container.

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

Influence of scoped styles on external webpages

I'm facing an issue with my nuxt app where I have two pages, each with different background styles. However, the background of one page is overriding the other. index.vue <style scoped> body { background-color: #ffffff; } #banner { backgr ...

Using JQuery and PHP to handle a click event on a webpage

To monitor and handle the click of a button on my page, I am looking to trigger a POST request to delete a specific course from the database by sending its course ID to PHP. Here's what I have implemented: Within a table displaying course details, th ...

Implementing real-time updates on controls located outside of a UserControl using RadAjaxManager

Currently, I am facing an issue with a selection dialog that is being shown by a RadToolTipManager. This dialog comprises several inputs, a RadGrid, and a button enclosed within a User Control. The issue arises when the user clicks the button, as the selec ...

What could be the reason for receiving an "undefined" response in my API ajax

I'm encountering an issue while attempting to call my API using a search term from a submit form. I keep getting an error that says "cannot read properties of undefined." I'm unsure why there is no data being returned when I send the ajax request ...

modifying the url using jquery

can someone help me modify a URL using this specific script as a guide? i need to change the URL from: \Administrator to: \Administrator ...

methods for retrieving data from a Laravel controller within an imported JavaScript file

My current approach involves using ajax to update a table based on the user's input. $('#user').change(function(){ var user= $("#user").val(); if (user !='None'){ $.ajax({ type: "GET", url: '/getUserAccounts/&a ...

Troubleshooting Alignment Problems in HTML5 and CSS

Check out my awesome page here: My Page To help with troubleshooting, I've assigned different background colors to the 3 sections of my page. The "Zine" should be red, the "Book Cover" green, and the "Magazine" yellow. However, I'm experiencing ...

Refresh Ajax/Javascripts following the loading of new data with .html() function

My website has a page that utilizes an ajax function to load data into the page. The ajax function is as follows: $(document).ready(function(){ function loadData(page){ $.ajax ...

I am attempting to fetch the posts using an ajax call, however, I am encountering a server error 500 with Wordpress Ajax

After clicking on a pagination link (page number), the post_type, taxonomy, and term_name are retrieved. Using JQuery Variables, these variables are passed to an Ajax WordPress function. Although the Ajax function successfully receives the variables, the W ...

What's the reason behind beforeunload not triggering?

I've gone through numerous similar posts, but I'm struggling to figure out what's not quite right with this code snippet: $(window).on("beforeunload", function () { debugger handleBeforeUnload(); return false; }); function handl ...

Creating a full-width tab card with Bootstrap-Vue: A step-by-step guide

I stumbled upon something similar in the documentation for bootstrap-vue: A card with tabs: https://i.sstatic.net/HoVEC.png Now, how can I style the tabs to look like this: https://i.sstatic.net/dbsRj.png This is my current code: <b-card no-body ...

The function appears to be failing to execute

I'm currently working on a dynamic search bar using AJAX to retrieve results from a database. I've noticed that when I check in the debugger, the code isn't triggering the handleSuggest() function which is responsible for updating the inner ...

Leverage Jasmine for testing a jQuery plugin

I'm currently utilizing the angular-minicolors library () within an angular controller: angular.element("myelement").minicolors({ position: 'top left', change: function() { //custom code to run upon color change } }) Wh ...

Issue with Kendo Grid filter box functionality specifically in Google Chrome, as it does not properly function; however,

Recently, I've been delving into Kendo-Grid for my work. While I'm still fairly new to using Kendo, I've encountered an issue with the filter functionality in the grid. Strangely enough, the filters work perfectly fine in Internet Explorer b ...

What causes an absolutely positioned element to be positioned by its sibling rather than at the top corner of the page?

Can someone explain to me why my absolutely positioned element is displaying after my child_static div? I'm under the impression that absolutely positioned elements are removed from the normal flow. So why isn't child_absolute covering the child_ ...

Is there a way to dynamically change the title of a tab when new content is added to a minimized page?

Is anyone familiar with how websites like Facebook and Buzzfeed update their tab titles when there are multiple tabs open? I have noticed that sometimes they add a "(1)" or "(2)" to indicate changes on the page. Do they use JavaScript to achieve this eff ...

Refresh the DIV element that houses dynamically generated <ul> HTML content after submitting new inputs

UPDATE: After delving into the code of nested include files in the child PHP file, I've identified conflicts with the parent PHP include files. This means that the child PHP file/div relies on the parent being refreshed, preventing me from refreshing ...

How can you display or conceal an HTML page in Jquery Mobile?

This code snippet is used for toggling the visibility of a div. $("[id*=viewMeButton]").click(function(){ $("[id*=viewMe]").toggle(); $("[id*=viewMeButton]").show(); }); In Jquery Mobile, similar functionality can be implemented to show/hide a ...

Tips for retrieving text without a class or id using selenium and python

I am attempting to extract a list of variables (date, size, medium, etc.) from the following webpage using python/selenium: Getting the titles was straightforward with: titles = driver.find_elements_by_class_name("sln_lot_show") for title in titles ...

Tips for testing an HTML email in different email platforms before finalizing the send. Utilizing PHP and Javascript for optimum results

After creating a web app that sends HTML emails using PHP, I wanted to implement a feature that allows users to preview how the email will appear in different email clients such as Outlook and Gmail before sending it out. Despite searching for plugins tha ...