The fixed position with bottom at 0 is not displayed on the Chrome browser until a refresh is done

When accessing my React front end in Mobile Chrome browsers, I noticed that the div at the bottom only renders after moving or refreshing the page. Interestingly, it works perfectly fine once cached. However, on the initial load (especially when using incognito mode), the div is not visible.

In contrast, Mobile Firefox displays the div immediately but requires adjustment when the URL bar disappears to maintain its position at the bottom, resulting in a slightly glitchy appearance.

Anchoring the div to the top works seamlessly across all browsers despite using the same codebase. My development setup includes a Docker container for React deployed via Node.js and Vite.js, with local development being conducted.

I have invested significant time trying to troubleshoot this issue without success. Any assistance or suggestions would be greatly appreciated - thank you!



<!doctype html>
<html lang="en">
  <head>
    <script type="module">import { injectIntoGlobalHook } from "/@react-refresh";
injectIntoGlobalHook(window);
window.$RefreshReg$ = () => {};
window.$RefreshSig$ = () => (type) => type;</script>

    <script type="module" src="/@vite/client"></script>

    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Vite + React + TS</title>
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="/src/main.tsx?t=1707096700138"></script>
  </body>
</html>
lang-jsx
import "./App.css";

function App() {
  return (
    <>
          <div style={{
  position: 'sticky',
  top: 0,
  minWidth: '100%', 
}}>Header</div>

<div style={{
  minWidth: '100%', 
  minHeight: '100vh',
}}>SOME CONTENT</div>

<div style={{
  minWidth: '100%', 
  minHeight: '100vh', 
}}>SOME CONTENT</div>

<div style={{
  position: 'fixed',
  bottom: 0,
  minWidth: '100%',
}}>Footer</div>
    </>
  );
}

export default App;
#root {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
    text-align: center;
  }
  
  .logo {
    height: 6em;
    padding: 1.5em;
    will-change: filter;
    transition: filter 300ms;
  }
  .logo:hover {
    filter: drop-shadow(0 0 2em #646cffaa);
  }
  .logo.react:hover {
    filter: drop-shadow(0 0 2em #61dafbaa);
  }
  
  @keyframes logo-spin {
    from {
      transform: rotate(0deg);
    }
    to {
      transform: rotate(360deg);
    }
  }
  
  @media (prefers-reduced-motion: no-preference) {
    a:nth-of-type(2) .logo {
      animation: logo-spin infinite 20s linear;
    }
  }
  
  .card {
    padding: 2em;
  }
  
  .read-the-docs {
    color: #888;
  } 

Various attempts like utilizing animations, sticky positioning, and other methods were made to resolve the issue but to no avail. The div does not appear in developer tools on desktop either, complicating UI creation. Despite simplifying the app components, the problem persists.

Answer №1

Through a series of experiments and beginning with a simple installation containing only four div elements, I was able to identify the root cause of the problem. It turns out that the issue stemmed from not allowing the Chrome browser to fully load before accessing my site. By patiently waiting 1-2 seconds, the bottom bar loads without any issues.

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

What is the best way to implement scrollToOffset in React Native while using useEffect?

I am attempting to achieve a specific behavior where, upon first rendering, the view scrolls down by an offset value of 493 using useEffect and scrollToOffset. However, I have noticed that this behavior doesn't work on the initial render but only kick ...

Troubleshooting Node API: Express body-parser update causing malfunction, message log indicates body-parser deprecated

Hopefully, I just need help updating the deprecated body-parser node module? I run an AWS instance with the bitnami Parse-Server installed through the AWS marketplace for an iOS app backend. The app suddenly crashed without any code changes in either the ...

Opting for babel.js over browserify for compiling into a bundle

Exploring the capabilities of babel.js to harness JavaScript ES6 features, I encountered a hurdle. As I construct my application using browserify and reactify, I utilize the command below: browserify -t reactify app/main.js -o public/scripts/bundle.js H ...

Is it feasible to view images in various formats?

I have provided the code snippet below: <CardMedia className={classes.cardMedia} image={`/items/${item.ID}.svg`} style={{ width: "50%", height: "50%", paddingTop: "20%", }} component="img" /& ...

Arranging images in a dynamic layout, either next to each other or on top of one

Currently, I am tackling a project involving two images of the human body - one for the front and one for the back. Both images are set at a height of 80vh. The challenge lies in my use of bootstrap to align these images side by side when the screen is wid ...

Unable to alter the background color in a table row when a condition is verified

Within my 'work' array that is generated from an Excel file, I have values for employee_id (referred to as id), projects, and hours. Additionally, I have another array called 'employees' which contains all the employees in my database. ...

Using Restify to Serve CSS FilesLearn how to use Restify to

Currently, I am developing a node application that requires serving static files like JavaScript and CSS. In my project structure, I have the following layout: -MyProject -backend -index.js -frontEnd -index.html -js ...

Adjusting the primary or secondary color of Material UI Chip

I've been attempting to dynamically alter the color of a Material UI Chip without much success. Based on the information provided in the Chip API, it seems that one must specify the color using the color prop with options from an enum: default, primar ...

Gain access to Google Analytics without the need for page consent by utilizing JavaScript

I am currently building a dashboard with Atlasboard. My goal is to retrieve Google analytics data such as page views, and I plan to run specific queries which can be found here. Is there a method to access my Google analytics data without the consent pag ...

Issue: NG0900: Encountered an error while attempting to differentiate '[object Object]'. Only arrays and iterables are permitted

I'm currently working on the frontend development of a crud application. While implementing lazy pagination, I encountered an error Error: NG0900: Error trying to diff '[object Object]'. Only arrays and iterables are allowed I have search ...

Enhance your React Datepicker with additional buttons to navigate to previous and upcoming years

In my current project, I am utilizing the react-datepicker library to collect the user's precise date of birth. Since a dropdown won't suffice in this scenario, a datepicker is necessary. However, an issue arises where there are only options to ...

Forward ReactJS

https://i.stack.imgur.com/r0IAE.pngI'm having trouble implementing a redirect to a submit confirmation page after pressing the submit button on my form. The backend server is set up to send an email upon submission, but adding an href to the button pr ...

TypeScript - patiently anticipating the completion of nested for loops

Currently, I am working on a task that involves implementing two nested for loops in my code. The primary objective of the first loop is to make an API call, which is dependent on the IDs selected by the user. Unfortunately, the limitation of passing only ...

I require the flexbox children to be arranged in a regular manner

How can we set flexbox children to default layout behaviors? Let's make them behave like the disobedient kids they are. .wrapper { This should be a row } .column { Make all heights equal display: flex; } .child { Back to regular display...wit ...

Issue arises in discord.js unban command if an identifier is not provided for the unbanning process

I have been following a tutorial series on developing a discord.js bot, but I encountered an issue that I am unable to resolve. The command works perfectly when an id is given, but it fails to display the error line as expected when no input is provided, r ...

A minuscule variation in width percentage due to a single pixel

I am experiencing an issue with a one pixel margin between two green colors on my website. I have been unable to locate the source of this problem. I am currently using display:inline-block. Here is the link to my website: ...

Is there a way to configure tsconfig so that it can properly recognize ".graphql" files and aliases when they are imported into components?

Currently, I have encountered an issue where including "graphql" files in my components is leading to TypeScript errors due to unrecognized import pathing. Despite the error, the functionality works as expected. import QUERY_GET_CATS from "@gql/GetCats.gra ...

Interactive material design drop-down menu

Currently, I am working on a dynamic drop-down menu that utilizes material-ui js. However, I have encountered an issue where clicking on one menu opens all the menus simultaneously, and vice versa when trying to close them. If you would like to view the c ...

"NodeJS applications using MongoDB always face the challenge of data expiring after only one

Utilizing the MongoDB npm module in my node application, I have implemented the following code to create a new item in the collection with a TTL index: var utcDate = new Date(); var emailObj = {email: emailAddress, createdAt: utcDate}; dbo.collection("ini ...

Sending images from a C# application to a NodeJS Express server using the PUT method through HttpWebRequest

I have a C# code snippet that is successfully working with another NodeJS Express application, the source code of which I do not have access to. However, I want to keep this code unchanged. string filetoupload = @"D:\testvideo.mp4"; HttpWeb ...