Floating box remains fixed at the top of the screen

While exploring the web, I stumbled upon a hotspot/popup that I added to my page. Unfortunately, I lost the link to the website where I found it. Somehow, after making some changes, the popup now appears at the top of the image rather than aligned with the pins on the left and right sides. When viewing the image, the popup should be near the red pin for Wk6. I'm puzzled about what caused this misalignment. The website in question is located at

Your assistance would be greatly appreciated.

HTML:

<!DOCTYPE html>
  <html>
    <head>
      <title>Second Air Force</title>
      <meta charset="UTF-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <link rel="stylesheet" href="./css/styles.css?v=<?php echo time(); ?>">
    </head>
    <body>
      .... (Content here)
    </body>
  </html>

CSS:

* {
  margin: 0;
  padding: 0;
}
body {
  background-color: #112349;
}

h1{
  font-size: 6rem;
}
... (CSS continues)

Answer №1

When the window's content is fully loaded, the event listener <quot;DOMContentLoaded"
isn't quite getting the job done. It seems to be running about 50ms late, causing the top pins to display correctly while the lower pins remain stuck at the top of the page.

Insight:

To troubleshoot this issue using DevTools, navigate to the Sources tab and open Booth.php. Click on line number 232 in the left margin to set a breakpoint there. Upon refreshing the page with Ctrl F5 (keeping DevTools open), you'll notice that all pins are aligned at the top of the page when JavaScript captures their positions, resulting in popups appearing at the page's top.

If you place the breakpoint at line 237 instead, let the script pause at that point, remove the breakpoint by clicking again, and hit the |> (play) button in the right-side panel, you'll observe all pins settling into their correct positions on the page as the JavaScript forEach loop logs their accurate coordinates for future reference.

Resolution:

Enclose your invocation of the contentPosition() function within a setTimeout or devise a new function to handle this task. One potential approach involves:

window.addEventListener("DOMContentLoaded", waitThenDo);

function waitThenDo(){
   setTimeout( () => {
      contentPosition();
   }, 500);
}

The provided solution introduces a half-second delay (500ms) before executing the contentPosition() function. Experimenting with this timing may yield optimal results, potentially reducing the delay below 100ms - not that anyone would discern a noticeable lag even if it extended to 2000ms...

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

It is not possible to modify the appearance of visited :before pseudo-elements

After attempting to enhance the appearance of visited links with various effects, I encountered an issue. Below is the code snippet in question: It seems that only Opera browser is able to modify the content of the :before pseudo-elements successfully. O ...

The JAWR generator is having trouble locating the jawr_generator.css file when using Less to compile it

I'm encountering some issues while trying to integrate JAWR with the generator configuration for converting less into CSS post compile. When I attempt this, I consistently run into errors where it's looking for a jawr_generator.css file that I be ...

Having trouble uploading a file in PDF format (*.pdf)

I'm attempting to use Node's readFile method to read a file and then send it as a response so that the user can download it. This is the code snippet I have: async function(req, res, next) { const query = { id: req.params.id }; // @ts-ignore co ...

Error in jQuery: Unexpected token ILLEGAL during Asp.Net page loading

I am encountering an issue with using jQuery where even simple functions are causing an error message Uncaught SyntaxError: Unexpected token ILLEGAL to appear on page load. Unfortunately, I do not possess enough knowledge about jQuery to troubleshoot such ...

Guide on toggling the button by clicking on the icon to turn it on or off

Within my angular application, I have implemented font icons alongside a toggle switch. Initially, the switch is in the ON state. The specific functionality desired is for clicking on an icon to change its color from white to red (this has been achieved) ...

Can a .obj file be loaded with colors even without an .mtl file?

Having just started with three.js, I encountered an issue. I created a 3D scan of my face and ended up with only an .obj file. When I view this file in Meshlab, the model appears textured. However, when I load it into three.js, the texture is missing. ...

Struggling with certain aspects while learning Nodejs and ES6 technologies

Below is an example of using the ES6 method.call() method that is causing an error var obj = { name: "Hello ES6 call", greet: function(somedata) { this.somedata = somedata console.log(this.somedata) ...

Tooltip not appearing when user hovers over it

I need help with displaying tooltips only when hovering over anchor tags. Initially, I have hidden the visibility and want to show it on hover. However, the tooltips are not appearing when I hover over them and there are no console errors displayed. Can so ...

Adjusting the object-fit property to "contain" and combining it with border-radius or exploring other alternatives can enhance

My goal is to showcase videos on a webpage while utilizing border-radius to round the corners for a more aesthetically pleasing look. The challenge arises as the videos come in varying aspect ratios, requiring them to be accommodated within containers wit ...

Move the width from left to right with animation

Currently, I am exploring ways to use jQuery to create an animation effect on a div where the width shrinks from left to right. My first step is to have the element animate as follows: Slide in from left to right Then continue moving to the right off th ...

Node.js HTTP requests

I am currently utilizing the code below to send a request to a host machine. Is there a way to include json data along with options? var options = { host: '172.16.2.51', port: 9090, path: '/start', ...

The fetch API is being restricted, however, AJAX and XHR are still operational

I made an API call to a URL shortener and encountered different responses using Fetch, JQuery, and XHR. Why is Fetch returning a 400 error while the other methods work smoothly? Even after trying mode: 'no-cors' and "crossDomain": true in the re ...

Unable to click on element at coordinates (x,y) with Protractor due to ng-change event

<select id="cbCategory" ui-select2 name="cbCategory" ng-model="categoryCombo.category" class="show-tick form-control comboBlue" ng-change="loadPrice()" required> <option ng-repeat="category in Categories" value="{{category}}" ...

Guide on how to retrieve a button background image from another website in PHP using the style attribute

When I try to open a gif file at this URL (http:/www.adlogic.com.au/recruiter_skin/rubicor/jamesgall/template/myWebsite_def_templ/roundbutton2.gif) in a browser, it opens without any issues. However, when I add the same gif URL in a style attribute, the g ...

The CSS 'top' attribute is without impact

As I begin my journey with CSS, I am eager to grasp some of its behaviors. In the CSS file, the following code is defined: #spa { position : absolute; top : 8px; left : 8px; bottom : 8px; right : 8px; min-height : 500px; min-width : 500px ...

What are the time-saving benefits of utilizing semantic X/HTML in CSS development?

Exploring the Time-Saving Power of Semantic X/HTML Markup - Streamlining CSS writing for websites Adapting to future design changes from clients with ease Avoiding the time-consuming nature of Table-based layouts in all scenarios Today, I have the task ...

The table borders in IE 11 do not display properly when using Html5 and CSS

In a previous version, the table had visible borders. However, when I added the property text-align:center; to my container, the table did not align to the center. I then tried adding display:inline-block; to the table, which successfully centered it. It l ...

Is it necessary to use Hapi.js on the client side in order to establish a websocket connection using the Hapi.js protocol?

Currently, I am in the process of developing an API using Hapi and requiring WebSocket functionality. After some research, it appears that Nes is the preferred choice to integrate with Hapi for this purpose. Fortunately, Nes simplifies the process signific ...

Tips for properly utilizing "require" in application.css with the Skeleton framework

I am currently working on implementing the skeleton-rails CSS framework into my application. Within the app/views/layouts/application.html.erb file, I have created containers and a list nav that require styling. Following the guidelines provided by the ske ...

storing HTML elements in Chrome's cache

I have developed a content uploading module that utilizes the file API. The HTML code is <input type="file" id="filepicker-input" multiple="true" style="display:none;"/> <div class="addfile_btndiv" id="addfile_btndiv"> ...