Issue with jquery mobile 1.42 causing white space at the bottom of all screens

Hey there! I'm currently working on developing a web application using jQuery Mobile 1.42. So far, everything has been running smoothly except for this pesky white space that keeps appearing at the bottom of each page. I only have a header and content section - no footer. Can anyone offer any guidance or assistance with this issue? Thanks in advance!

Answer №1

To grasp the functioning of jQuery Mobile pages, it's crucial to understand that the header and footer have fixed height values while the content is flexible. The content will adjust its size based on its inner content rather than automatically resizing to fill the remaining space below the header and above the footer. This creates the white space you've observed.

Two solutions are available for your issue: a CSS-based solution and a JavaScript-based one.

CSS Solution:

.ui-content {
    padding: 0;
    position: absolute !important;
    top : 40px !important; 
    right : 0;
    bottom : 40px !important; 
    left : 0 !important;    
}

The 40px value accounts for the header and footer heights; set it to 0 if they're not needed.

View working example here.

JavaScript Solution:

function getRealContentHeight() {
    var header = $.mobile.activePage.find("div[data-role='header']:visible");
    var footer = $.mobile.activePage.find("div[data-role='footer']:visible");
    var content = $.mobile.activePage.find("div[data-role='content']:visible:visible");
    var viewport_height = $(window).height();
 
    var content_height = viewport_height - header.outerHeight() - footer.outerHeight();
    if((content.outerHeight() - header.outerHeight() - footer.outerHeight()) <= viewport_height) {
        content_height -= (content.outerHeight() - content.height());
    }
    return content_height;
}

View working example here.

For more information on this topic, read further here.

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

Tips for adjusting an @media css for a material-ui react component

After posting this inquiry about overriding a CSS property in a material-ui component, I received a helpful example. However, I encountered difficulty when attempting to set the height of the Toolbar component due to an overarching @media specification. My ...

Using AJAX in Rails to dynamically display information in a div on the webpage

In my project, I have a model named Area and what I want to achieve in the index page is loading the area_path(area) within a div element instead of redirecting users to another page. Here are the code snippets that I have implemented so far: <h3>W ...

Tips on submitting an HTML form, utilizing ajax for processing, and showcasing PHP variable within a DIV on the current page

After struggling for over 6 hours, I've finally mustered up the courage to ask this question. My eyes are practically crossed from all the effort! Despite having some experience with PHP and HTML, Ajax and jQuery are completely new territories for me ...

How to use the transform function in JavaScript

Hey there, I'm looking to create a new function. I am just starting out with javascript. I want to wrap the code below in a function like: ConfirmDelete() { }; This function should perform the same action as this code snippet: $('.btn-danger ...

Having trouble with jQuery's remove parent tr function not functioning properly on the initial attempt

I am facing an issue with deleting a parent tr element on the first click of the delete button. When I click on the delete button, it blinks and does not remove the tr on the first click. However, when I click the delete button for the second time, it fi ...

How to Retrieve Content from an iFrame Using jQuery?

I am facing a challenge with an HTML form that is directed to an IFRAME upon clicking "submit". The iframe then loads a page after the submission, which indicates whether the user-input data is valid or not. It simply displays on screen as "TRUE" or "FALSE ...

Issue with modal dialog not triggering onshow event after postback

In my application, I have a Bootstrap modal dialog that is used to display data when the user clicks on "Edit" in a jQuery data table. The modal contains Cancel and Submit buttons. Everything works correctly when I open the modal, click Cancel, select ano ...

Utilizing the dynamic duo of Jquery and ColdFusion

My webpage needs to display results, and I'm using jQuery with JSON to retrieve and show the results. However, the results are not appearing in the appropriate div when a user hovers over the relevant image. Here is the script I am using: <style&g ...

Trigger the show.bs.modal event prior to the parent event being called

In my Bootstrap website (built with Bootstrap 4), I have a button that triggers a modal and transfers the data from the button to the form inside the modal using the following function: $('#exampleModal').on('show.bs.modal', function ( ...

Tutorial on wrapping HTML content in a CDATA tag using jQuery

Is there a way to enclose some HTML in an element using a CDATA tag to "sterilize" it, so to speak? I've attempted to do so using the following code: $(this).html( "<![CDATA[" + $(this).html() + "]]>" ); However, this approach simply encodes ...

Looking to modify the CSS of an element during a drop event using interact.js?

I've encountered an issue in my code where setAttribute and .transform are not working as expected. I have tried using them within the ondrop event function, but with no success. interact('.dropzone') .dropzone({ // Setting the r ...

Creating a responsive div class that is centered

Struggling to center my <div class="loginfeld"> while keeping it responsive. <html> <body> <div class ="loginfeld"> <div class="container"> <div class="col-lg-4"></div> ...

What sequence of events occurs when the submit button is clicked within a view?

Can you explain the step-by-step flow of actions and rendering when I click the submit button that calls a JavaScript function and posts to a controller? @section impScripts { <script type="text/javascript"> functi ...

Methods for concealing the title and date when printing web content using JavaScript

When utilizing the window.print method to print out a specific screen, I encountered an issue. I need to hide the date in the top left corner of the image as well as the title (not the big heading) which has been intentionally blurred. I've come acro ...

Adjusting Grid Posts to a Consistent Size (Featuring Photo Posts with Captions Below)

I'm attempting to adjust the size of posts in grid mode on Tumblr. I've discovered that I can modify the width of each post using CSS. However, I'm struggling to locate where I can set the height of a grid post to a specific size. For inst ...

The blinking cursor in Google Docs is known as "kix-cursor-caret."

Although I adore Google Docs, I can't help but find the blinking cursor a bit too distracting for my liking. It seems that the latest version of Google Docs fails to comply with the operating system's setting for displaying a solid, non-blinking ...

Discover the true width of the unordered list structure Forest

One of my projects involves creating family trees using CSS and unordered lists. It works great, except when the tree is wider than the screen, causing it to wrap awkwardly. To solve this issue, I implemented the following CSS: #treewrapper { margin: 10px ...

An effective method for finding a key in a multi-dimensional array or object based on its value using JavaScript and/or jQuery

I have a unique object structure that resembles the following: var data = {}; data.items = { name : 'apple', price : '$1.00' }; data.products = { name : 'banana', price : '$0.50' }; data.goods = { name : 'oran ...

Struggling to incorporate a three-strike mechanism into my JavaScript game

I need to implement a feature where the user can make up to 2 mistakes before losing the game. Here's what I need to do: - Set up a global variable to keep track of the number of mistakes - Initialize this variable during the startGame function - M ...

Safari causing issues with AJAX requests when using HTTPS

While I'm not an expert in ajax, the request I have is quite simple: $.ajax({ url: "https://62.72.93.18/index.php?a=get_lights", dataType: 'jsonp', success: function (res) { notify ? jsonLightsDone(re ...