Placing a moving element over an image

I'm currently developing a solar system viewer app that features 8 objects orbiting a central point using a specific method.

.orbitContainer {
  
  width:var(--s);
  height:var(--s);
  margin:auto;
  text-align: center;
  border-radius: 50%;
  animation: spin var(--d) linear infinite, translateBackground 100s infinite linear; 
  transform:rotate(0) translate(var(--o)) rotate(0);
} 
@keyframes spin {
  100% {
    transform:rotate(1turn) translate(var(--o)) rotate(-1turn);
  }
}
.mercuryPath {
  --d:20s; 
  --o:4.5rem;
  --s: 12rem;
  z-index: 9;
}

Everything is functioning well, except for the 6th object which happens to be Saturn with its distinct rings. I'm attempting to overlay an image of the rings onto the element representing Saturn.
Here's what I've tried so far:

<div className="orbitContainer saturnPath" >
<MiniPlanet name="saturn" className="orbitContainer saturnMini " />
<img src="./components/planetTextures/rongs.png" alt="rings"></img></div>

I initially thought that by placing the image within the same path container as the planet, it would rotate in a synchronized manner. However, it seems to move randomly around instead.

I'd appreciate suggestions on how to effectively overlay the rings on the planet, or any alternative methods to achieve this. Due to each planet having unique atmospheric effects, using a static image of Saturn with rings is not feasible.

Here is a codesandbox link showcasing my code.

Answer №1

The issue at hand is that the rings are not aligning with the planet's path; instead, they are contained within the same outer div. Furthermore, it seems that the rings image is missing the necessary 'rings' class.

Since I don't have access to the rings image, I couldn't test placing it exactly around Saturn. However, by moving the image into the orbiting element and adding the class, I was able to see the word 'rings' circling above Saturn correctly.

Give this a try:

<div class="orbitContainer saturnPath">
  <div class="miniPlanet">
    <a href="/saturn">
      <div class="orbitContainer saturnMini ">
        <img src="./components/planetTextures/rongs.png" alt="rings" class="rings">
      </div>
    </a>
  </div>
</div>

On a side note: it might be confusing to have both the outer div 'saturnPath' and inner div 'saturnMini' with the same orbitContainer class. Does this setup provide the desired orbits?

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

The additional cost associated with using a React hook is called the "

Our system includes a theme context provider that passes down a theme to all child components, calculated based on the device's dimensions. We can easily access these values using the useTheme hook in any component. In addition, we have a constants f ...

Tips for setting up the information in a Bootstrap popover

I am currently working on a Google web app that involves Google Sheets data. My objective is to have the data displayed when hovering over a button, but instead, the data appears directly on the button without the hover display. What might I have done in ...

Struggling to create a mobile-friendly design

I've successfully created a dynamic world map using D3.js, but I need some guidance on making it responsive across various screen sizes. You can view the interactive world map here. Credentials to access the map: Username: DXLdemo Password: ...

Tips for saving the visibility status of a <div> in your browser bookmarks?

Currently, I am in the process of developing a single webpage (index.html). The navigation bar at the top includes links to hash references (DIV IDs). If JavaScript is enabled, clicking on these links triggers a JavaScript function with the onclick attribu ...

Refine Your Search Findings

I have a code snippet that enables searching items from a dropdown menu with a search bar, but now I want to remove the dropdown and only keep the search functionality. How can I modify the code to separate the select feature from the independent search ...

employing iframes dynamically to overlay a webpage

I inserted this iframe into a webpage <iframe src='http://redbug.redrocksoftware.com.au:80/Pages/chamara.html' style="position:absolute;z-index:1;" ></iframe> The chamara.html page has a button that, when clicked, should cover the c ...

Conceal the name of the component in the URL within the navigator

Is there a way to conceal the name of components accessed through the URL, for example when visiting http://localhost:3000/ParametrageAgence.jsx? How can I hide the 'ParametrageAgence.jsx' part and potentially encode it for additional security? ...

The class type "selectLabel" passed to the classes property in index.js:1 for Material-UI is not recognized in the ForwardRef(TablePagination) component

Just started using react and encountering a repetitive error in the console after adding this new component. Here is the full error message: Material-UI: The key selectLabel provided to the classes prop is not implemented in ForwardRef(TablePagination). ...

modifying the appearance of the parent container of an input element

I'm trying to change the style of a parent element when its child input is checked. <div> <!--- this is the parent element ---> <input type="radio" data-dynamic-update="1" name="virtuemart_paymentmethod_id" id="payment_id_3" value= ...

Tips for customizing the base font size in a Bootstrap 4 template

My Java/Spring Boot webapp utilizes Thymeleaf HTML page templates and Bootstrap 4, with the foundation being a free Bootstrap 4 site template called 'Simple Sidebar': . The current setup is functioning smoothly for me. I am interested in adjusti ...

Struggling with Bootstrap's responsive design: Ensuring images remain anchored at the bottom of a div

I recently integrated the Bootstrap product example into my website, located at https://getbootstrap.com/docs/5.0/examples/product/. Everything works well except for a minor issue I encountered on iPads or when zooming in on computers - the images on the w ...

CSS hover image resizing not functioning as expected

Is there a way to dynamically scale up an image when hovered over? I'm trying to achieve an effect where the image increases from 100x75 pixels to 300x225 pixels. Everything seems to be working fine with the layout, but the width doesn't seem to ...

Determining the cursor's location within a textarea element

I am currently working on a React Project and I have a specific functionality in mind. I want to create a feature where as a user types into a Textarea, suggestions will appear in the form of a popover list right next to the cursor position. To implement ...

Is it possible to include Helvetica or a similar font in my web application for shipping?

My web-app is Java/HTML based and hosted on the cloud. Users will access it using IE, Chrome or Mozilla. I would like to use Helvetica or a similar font, but they are not readily available on most systems (windows/IE/Chrome/Mozilla). Is there a way for me ...

What could be the reason that my Bootstrap dropdown menu is not appearing on my website

I am currently utilizing Angular in my project. I have incorporated bootstrap and jQuery via NPM install, and specified them as dependencies in angular.json. The navbar on my site contains a dropdown menu. When I hover over the dropdown menu, it should di ...

Encountering a FirebaseError while executing a Firebase query with a "

I'm currently using "firebase": "^9.9.0", which means I am working with web version 9 syntax. My goal is to retrieve a document based on its field value, but I've been encountering difficulties. Despite being able to fetch all ...

Creating a dynamic state for multiple collapsible components in a functional component

I am looking to create collapsible items for each data entry in my state, where a user can simply click on each item to expand it. Below are the code snippets I have been working with: import ListSubheader from '@mui/material/ListSubheader'; i ...

Navigating to the appropriate section by clicking on a navbar item with Bootstrap 5: A step-by-step guide

Hi everyone! I am just starting out in front-end development and I was hoping to get some clarification on a topic. I need to create a one-page website where the navigation bar links scroll down to the correct sections when clicked. It's all on one pa ...

What is the best way to show an HTML response from an API call on the DOM?

After making an API call, I receive the following HTML response and I am trying to display it on the DOM as actual HTML tags, rather than just showing text with HTML tags. API response: <strong>Hello</strong> Current DOM rendering: <str ...

Problem with the position of Bootstrap 3.3.4 navigation bar

Check out the Markup: <div class="navbar navbar-inverse navbar-static-top"> <div class="container"> <a href="index.html" class="navbar-brand">Kellumonline</a> <button class="navbar-toggle" data-to ...