When clicking, the fixed header and footer suddenly shift out of place

In my jquery mobile application, I am facing an issue with a fixed header and footer. Whenever I click on the screen, the fixed header and footer get displaced and are no longer fixed. I am unsure how to resolve this bug. Any suggestions on how to fix it would be greatly appreciated. I have created a JSFiddle for reference.

    <div style="height:100%; width:100%" class="ui-page" data-role="page" data-position="fixed" id="main">
        <div style="height:10%"" data-role="header" data-position="fixed"> 
            <a class="ui-btn-left" name="backo" data-icon="back" data-rel="button" ></a>

        <h1>title</h1>
        </div>
        <div style="height:100%; width:100%" data-role="content" id="container">
<ul data-role="listview" data-inset="true" class="ui-listview ui-listview-inset ui-corner-all ui-shadow">
    <div style="width:95%;padding-right:5%;" id="chatOutput">

    </div>
    </ul>
        <div style="height:15%; width:100%;background-color:#e9eaed;border: 0px;border-color: transparent;" data-role="footer" data-position="fixed">

    <div style="width:96%;padding-right:2%;padding-left:2%" class="ui-grid-a">
        <div style="height:100%;width:80%" class="ui-block-a"><input type="text" id="chatText" paceholder="type your text here"></div>
        <div style="height:100%;width:20%" class="ui-block-b"><button style="font-size:90%" class="ui-btn ui-shadow ui-icon-carat-r" id="chatSend">send</button></div></div>

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

EDIT: After some research, I came across this solution:

$("[data-role=header]").toolbar({ tapToggle: false });
, which has resolved the issue for me.

Answer №1

Insert data-tap-toggle="false" within the opening and closing tags of the header and footer sections.

By doing this, you can disable the toggling effect of the header and footer when tapped or clicked.

Answer №2

Modify the following:

<div style="height:10%"" data-role="header" data-position="fixed">

Change it to this:

<div data-role="header" data-position="fixed">

Additionally, update this:

<div style="height:15%; width:100%;background-color:#e9eaed;border: 0px;border-color: transparent;" data-role="footer" data-position="fixed">

To the following:

<div style="background-color:#e9eaed;border: 0px;border-color: transparent;" data-role="footer" data-position="fixed">

Check out the updated jsfiddle

Updated jsfiddle now includes a persistent message box


Some key points to consider:

  • Avoid using inline styling; opt for stylesheets for better organization.
  • Block elements like 'div' automatically expand to full width, so specifying width:100% is redundant.
  • Validate your HTML code for errors using browser developer tools or online validators like validator.w3.org

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

IE9 presents a frustrating issue where the jQuery select box value is returning as

I've been battling a bug for over 2 hours now. My javascript code is supposed to generate a two-level select box for tasks and subtasks from JSON data. However, I recently discovered that this code doesn't function properly on IE9, and possibly ...

D3: Ensuring Map is Scaled Correctly and Oriented Correctly

I am attempting to integrate a map into a website using D3 and topoJSON that resembles the following: https://i.sstatic.net/1brVx.png However, when I create the map with D3/topoJSON, it shows up small and inverted. https://i.sstatic.net/LgQBd.png Even ...

Tips for including headers with @Url.Action() to enable jwt authorization

When a user inputs correct login credentials, they should be redirected to the next page (LandingPage). However, upon clicking the Submit button, users are receiving a 401 unauthorized error instead of being directed to the next page. The JWT token is gene ...

Adding a subtle gradient to the image, just ahead of the SVG

Is there a way to achieve this particular look? https://i.stack.imgur.com/yQjvK.png I'm currently encountering this appearance issue. https://i.stack.imgur.com/eQjQ4.png Any suggestions on how I can make it match my desired outcome? Your assistan ...

Sprockets::FileNotFound - unable to locate the file named 'query.effects.core'

Whenever I try to access localhost:3000 after starting my Rails server, I keep encountering a "file not found" error. The specific message says couldn't find file 'jquery.effects.core'. Despite trying various solutions like pulling a fresh c ...

Trouble with predefined JavaScript in Mongodb situation

Encountering the error "Missing ";" before statement" in Mongodb Atlas Online is frustrating for me as a newbie. Despite my efforts, I can't seem to figure out why the following code snippets are causing this issue: const counter = await counterCollec ...

The inline HTML script was unable to execute the function as intended by Jquery

Attempting to remove the element using a custom function called within inline html on my script tag, below is the code: HTML <div id="form"> <input type="text" name="name", id="name"><br> <input type="text" name="address", id="ad ...

What is the best way to programmatically select a checkbox that was created dynamically using jQuery?

I've been scouring the internet trying to find information on what I'm attempting to accomplish, but so far I haven't come across anything helpful. The issue I'm facing is with a form that has a section dynamically added using JavaScri ...

After a group of floated items, there will be an automatic "clear: both" applied

Within my Content Management System, I have custom Elements that need to be floated next to each other. Instead of adding an extra div with a class of "clear", I want to automatically insert a clear: both at the end using CSS3. I attempted this workaround ...

Locate the closing anchor tag following the image

I need to locate the closing anchor tag that wraps an image with the class name "cat-image" in order to move a div right after it. However, I am unable to modify the HTML by adding IDs or classes to the anchor or image tags. Below is an example of the HTM ...

What is the best method for implementing pagination in Larvael with React using Inertia?

Is there a way to paginate in react using inertia with laravel? When pulling paginated data, I use the following code: $contacts = Contact::orderBy('name', 'asc')->paginate(10); return Inertia::render('Contacts/index', [ ...

Discover the position within a two-dimensional array

Suppose I have an array that contains objects, and each object has its own id property. In this case, I can find the index by writing: data.findIndex(x=>x.id === newData.id); Now, if data is an array of arrays of objects, how can I efficiently get two ...

The initialization of Firebase is not being completed before it is being called in other files

I am currently working on a vue project and I am attempting to integrate firebase. However, I have encountered an issue where my other JavaScript files like auth.js are utilizing firebase before it is properly initialized in my main.js file (which acts as ...

Guide to effectively utilizing jQuery Deferred within a loop

I have been working on a function that needs to loop through a dataset, updating values as it goes along using data from an asynchronous function. It is crucial for me to know when this function finishes running the loop and completes all updates. Here is ...

Transitioning from Three.js's CanvasRenderer to WebGLRenderer is a significant upgrade

Can a Three.js script created with CanvasRenderer be easily converted to use WebGLRenderer instead, and if yes, what is the process for doing so? ...

What could be causing the submenus in my intricate menu component to lose focus when input is entered?

I'm currently working on developing a menu using the MUI Menu component. The goal is to have a popup input control (such as Autocomplete, TextField, Select, or a custom form) appear when a menu item is clicked, based on the choice made from the menu. ...

Using JavaScript to open links in a new tab with the target

document.getElementById("mahacareer").onclick = function () { window.open("http://www.mahacareermitra.in", '_blank'); }; <a href="" id="mahacareer">Access the portal</a> Hi there, I am looking to have the link above open in a new tab ...

The X-frame-Options HTTP response header is ineffective

I've been attempting to implement the X-Frame-Options response header in my application by configuring it on my express server. Utilizing the helmet npm package, I've applied the following code snippet: const express = require("express" ...

Adjusting diagram size based on screen width using Bootstrap and jQuery

I recently created a diagram that adjusts its size according to the screen width. However, when I implemented this code on my page, I encountered an issue where the final circle or glyph would drop to the next line instead of staying on the same line as in ...

Error in NW.js file pattern: The package.json file was not found within the source directory file glob patterns

When trying to run a NW.js script located in the /tool/nw.js folder with a source folder set to /dist, an error related to the glob pattern not finding the srcDir (/dist) is thrown. While using glob:false in the configuration resolves the issue, I am curio ...