Arrange various images in a circular formation, rotate them in orbit, and show text within the circle upon hover using Bootstrap 4

I'm attempting to create a circle with various images circling around it, resembling planets in orbit. When hovering over these images, I want the rotation to pause and display different text in the center of the circle. While I've successfully drawn a perfect circle, I'm struggling with aligning the images around it and maintaining their continuous revolution. The image below illustrates my goal. https://i.sstatic.net/CopgG.png

Essentially, each smaller circle containing numbers represents an image. Upon hovering over these circles, unique text will appear at the center of the larger circle, halting the rotation. Additionally, I aim to make this project responsive by placing it within a container and accommodating it in col-3.

I'm currently facing challenges when it comes to aligning the images and presenting the text at the center of the circle. Here is what I have attempted thus far: HTML

        <div class="col-3 mx-auto" style="background-color: grey;">
            <img src="images/location/2x/location.png" style="float: left; ">
            <div class="circle">
                <div class="text-center">

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

CSS

.circle{
    width: 80%;
    height:0;
    padding-bottom: 80%;
    -moz-border-radius: 50%; 
    -webkit-border-radius: 50%; 
    border-radius: 50%;
    background: #4679BD;
}

What would be the most effective approach to accomplish this?
Any guidance?

Answer №1

My solution may not be flawless, but it can serve as a starting point.

If you want to display dynamic text, make use of the data-text attribute.

<img data-text="A" src="http://placehold.it/50x50" alt="">

To retrieve and update the text when hovering over images, an event listener for the mouseover event has been added to each image:

sampleText.innerHTML=this.getAttribute('data-text');

To halt the animation on hover, I have utilized the following CSS rule:

.image-holder:hover {
      animation-play-state: paused;
 }

var images = document.getElementsByTagName('img');
var sampleText = document.getElementById('sample-text');
for (var i = 0; i < images.length; i++) {
  images[i].addEventListener("mouseover", updateName)
}

function updateName() {
  sampleText.innerHTML = this.getAttribute('data-text');
}
/* CSS styles go here */
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
  <div class="row">
    <div class="parent">
      <div class="circle" id="sample-text">
        Sample Text
      </div>
      <div class="image-holder">
        <img data-text="A" src="http://placehold.it/50x50" alt="">
        <img data-text="B" src="http://placehold.it/50x50" alt="">
        <img data-text="C" src="http://placehold.it/50x50" alt="">
        <img data-text="D" src="http://placehold.it/50x50" alt="">
        <img data-text="E" src="http://placehold.it/50x50" alt="">
        <img data-text="F" src="http://placehold.it/50x50" alt="">
        <img data-text="G" src="http://placehold.it/50x50" alt="">
        <img data-text="H" src="http://placehold.it/50x50" alt="">
      </div>
    </div>
  </div>
</div>

Answer №2

Consider utilizing positioning properties to adjust the placement of your circle and text, as demonstrated below:

        .circle{
        width: 300px;
        height:300px;
        -moz-border-radius: 50%;
        -webkit-border-radius: 50%;
        border-radius: 50%;
        background:white;
        position: relative;
        }
        span{
          color: red;
          position: absolute;
          left: 130px;
          top: 50%;
        }
        img{
          position: absolute;
          left: 270px;
          top: 45px;
        }
    
    
         <div class="col-3 mx-auto" style="background-color: grey;">
                <img src="images/location/2x/location.png" style="float: left">
                <div class="circle">
                    <span>Hello</span>
                </div>
            </div>
    

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

Applying a CSS border to a div that perfectly encloses a span, adjusting to the

My goal is to create a nested structure where a div contains a span element like this: ---------- |Sentence| ---------- ----------------- |It's a looooong| |sentence | ----------------- While it works well for short sentences, long ones end u ...

jQuery issue with hover and mousedown

Hello everyone, I have a little challenge that I believe shouldn't be too complicated. What I want to achieve is displaying an image in a cell when the mouse hovers over it. Here's the setup: <table id="selectable"> <tr> ...

Achieve the same height for an HTML table as its parent div by adjusting the table's height when the div's height is not explicitly defined

I am facing a challenge with an html table placed inside a div. The height of the div is determined by other elements within it. Is there a way to make the table's height match that of its parent div? (setting the table height to 100% is not effecti ...

Struggling with Implementing Modals in Bootstrap 3.3.7

I've been encountering an issue with modal functionality. In order to troubleshoot my own modals, I decided to replicate the modal example code from Bootstrap's website into a new HTML file. Despite linking to the CDN, the modal does not functio ...

The issue of the fixed navbar overlapping the scrollbar of the page occurs when utilizing the overflow-y scroll feature

I am trying to create a web page with snap scroll and a fixed navbar that remains at the top. However, I'm facing an issue where the navbar is overlapping the right scroll bar, which should not be happening. If I remove the overflow-y property from th ...

Center the navigation links within the navigation block

I am using the startbootstrap-small-business template and customizing it to fit my requirements. I have inserted a new logo which caused me to adjust the height of the navbar to approximately 120px. Now, my goal is to vertically align the links on the righ ...

JavaScript/jQuery creation of a dynamic breadcrumb trail linked to the current page

After reviewing the question posted here, the answer seemed adequate for static navigation but lacks functionality for actual user navigation. I am in need of a custom Javascript/jQuery script that can dynamically generate breadcrumbs based on the URL of ...

Issue with Number Form Input in Firefox on BootstrapVue

I am currently working with BootstrapVue and have a specific input element within a b-form that I need assistance with: <b-form-input v-model="myTest" type="number" max="9999"></b-form-input> My goal is to achieve ...

Adaptable background images with CSS styling

I'm attempting to adjust the sizing of my background image on the splash page to make it smaller. My goal is for the image to fill the entire section regardless of screen size. .splash{ background-image: url("../images/lanternboys_medium.jpg"); backg ...

Submitting the form does not result in the textbox being cleared

I have been attempting to clear the txtSubTotal text box upon clicking the PROCEED button, but it seems that my efforts have been in vain despite trying various code examples, including those from SO. btnProceed/HTML <input type="submit" name="btnProc ...

What is the method for inserting line breaks in Ionic2 toasts using HTML?

Is there a way to include new lines and other HTML tags in a toast message? let toast = this.toastCtrl.create({ message: "First line<br />Second line.", duration: 5000, dismissOnPageChange: true }); toast.present( ...

What is the process for incorporating a Bootstrap 4 template into my Ember web project?

I previously shared a post on Stack Overflow about my attempt to incorporate the INSPINIA admin theme, which is built on Twitter Bootstrap, into an Ember application. You can view the initial post here. Having downloaded the INSPINIA theme that offers pre ...

Retrieve information from Wikipedia corresponding to the keyword entered in the form

Imagine a situation in which a user inputs a keyword into a text field. I am seeking a way to retrieve relevant data from Wikipedia that corresponds to the entered keyword. How can this be accomplished? <form method=POST action=someaction> ...

Changing the variable value upon clicking

When I click on an li, my goal is to retrieve the value of the data-currency attribute and store it in a var. This is the code I am using: $(function(){ var $currency = "€"; $('.pricingTable__dropdown-li').click(function(){ var dat ...

Validating the Color Coding of Backgrounds in a Table using Selenium WebDriver and Java

Can Xpath or another method be used to validate the Color Coded Background inside a Table for a specific Value? The background color in question is rgb(96,192,96). There are 5 different links on the page, each with the same background color. It is necessar ...

Can the ::before selector be used in HTML emails?

Hey there, I have a question that might sound silly but I'm having trouble finding an answer online. My issue is with styling the bullet point before a list item in an HTML email. All I want to do is change the bullet point to a square and give it a ...

Complete the submission of a form containing a dropdown field

I'm looking to accomplish a seemingly simple task, but I'm unsure how to do it: Within my table of records, I want to include a select field that displays different views based on the selection. Here's an example of what my select field loo ...

What steps can be taken to enable users to send and receive messages on my chat website?

I just completed creating a chat website using HTML, CSS, JavaScript, and jQuery and have now published it. You can view it at However, the site still lacks the functionality that would allow users to send and receive messages through it. Can anyone prov ...

Navigate to the page using PHP or JQuery

I am currently utilizing AJAX in a form where the user uploads their photo. The file is sent to PHP for verification, and a message is returned based on whether the process was successful or not. I am displaying the result within a paragraph tag, however, ...

Return to a natural position as the element becomes fixed

Apologies if this question has already been answered somewhere, but I have been unable to locate a solution (possibly due to my limited knowledge of the correct terminology). As I scroll on my webpage, I want 3 elements to become fixed once they reach a s ...