A guide on making interactive circular SVG image displays

I have a collection of svg files that fit together like pieces of a puzzle to form a circle. What would be the most effective way to arrange them? I attempted placing the segments within a ul with each on top of one another. Since the segment svgs are already correctly rotated, I assumed I could utilize display flex on the wrapper and add spacing between them using the 'gap' property, but unfortunately it doesn't seem to work.

This is my current code:

<div class="expertises-wrap">
    <ul class="expertises">
        <li>
            <img class="slice" src="img/infographic/techniek.svg">
        </li>
        <li>
            <img class="slice" src="img/infographic/aard-warmte-projecten.svg">
        </li>
        <li>
            <img class="slice" src="img/infographic/duurzame-energiezaken.svg">
        </li>
        <li>
            <img class="slice" src="img/infographic/modellering.svg">
        </li>
        <li>
            <img class="slice" src="img/infographic/ruimtelijke-ontwikkeling.svg">
        </li>
        <li>
            <img class="slice" src="img/infographic/corporate-finance.svg">
        </li>
        <li>
            <img class="slice" src="img/infographic/makelaardij.svg">
        </l
        i>
    </ul>
</div>

(S)CSS

.expertises {
    position: relative;
    width: 500px;
    height: 500px;
    list-style: none;
    display: flex;
    gap: 70px;
    justify-content: center;
    align-items: center;
    li {
        position:absolute;
        img{
            width: 250px;
            height: auto;
        }
    }
}

What would be the optimal approach for this scenario?

JSfiddle: https://jsfiddle.net/fyL4r0vu/

Intended result:

https://i.sstatic.net/shCNx.png

Answer ā„–1

To achieve this effect, start by centering all the images and then utilizing the transform property to position them as desired.

Begin with:

transform: rotate(0deg) translate(10em) rotate(0deg);

Gradually adjust the rotate and translate values for each image


If the positioning in your specific example is not aligned correctly, evenly space the images like so:

.image-holder {
  position: relative;
  width: 20em;
  height: 20em;
  border-radius: 50%;
  padding: 0;
  list-style: none;
  margin: 5em auto 0;
}
.image-holder > img {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -3em;
  width: 6em;
  height: 6em;
}
.image-holder > img:nth-of-type(1) {
  transform: rotate(0deg) translate(10em) rotate(0deg);
}
.image-holder > img:nth-of-type(2) {
  transform: rotate(45deg) translate(10em) rotate(-45deg);
}
.image-holder > img:nth-of-type(3) {
  transform: rotate(90deg) translate(10em) rotate(-90deg);
}
.image-holder > img:nth-of-type(4) {
  transform: rotate(135deg) translate(10em) rotate(-135deg);
}
.image-holder > img:nth-of-type(5) {
  transform: rotate(180deg) translate(10em) rotate(-180deg);
}
.image-holder > img:nth-of-type(6) {
  transform: rotate(225deg) translate(10em) rotate(-225deg);
}
.image-holder > img:nth-of-type(7) {
  transform: rotate(270deg) translate(10em) rotate(-270deg);
}
.image-holder > img:nth-of-type(8) {
  transform: rotate(315deg) translate(10em) rotate(-315deg);
}
<div class="image-holder">
  <img class='slice' src="https://placehold.jp/50x50.png?text=1" alt="">
  <img class='slice' src="https://placehold.jp/50x50.png?text=2" alt="">
  <img class='slice' src="https://placehold.jp/50x50.png?text=3" alt="">
  <img class='slice' src="https://placehold.jp/50x50.png?text=4" alt="">
  <img class='slice' src="https://placehold.jp/50x50.png?text=5" alt="">
  <img class='slice' src="https://placehold.jp/50x50.png?text=6" alt="">
  <img class='slice' src="https://placehold.jp/50x50.png?text=7" alt="">
  <img class='slice' src="https://placehold.jp/50x50.png?text=8" alt="">
</div>

Answer ā„–2

Have you considered utilizing SVG as a container? You can leverage the <image> element to embed images and use <a> tags for linking purposes.

With all the small SVG images already created, your main challenge now is arranging them in the correct size and position. It might be worth revisiting the source files to see if the sizing and positioning issues can be addressed there.

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
  <a href="#1">
    <image href="https://svgur.com/i/gUR.svg" width="40" x="30"/>
  </a>
  <a href="#2">
    <image href="https://svgur.com/i/gUQ.svg" width="38" x="58" y="5" />
  </a>
  <a href="#3">
    <image href="https://svgur.com/i/gTa.svg" width="33" x="64" y="38" />
  </a>
<svg>

Answer ā„–3

Creating a single SVG image with all the content is another option that can be pursued, even though it may consume some time. Here's how you can kickstart the process:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1700 1700" font-size="40" font-family="sans-serif" font-weight="bold" text-anchor="middle" dominant-baseline="middle">
  <path id="p1" d="M -348.917 -763.913 q 14.3 -6.534 28.831 -12.534 q 22.177 -9.132 44.8 -16.984 A 842.35 842.35 0 0 1 50.923 -838.5 c 1.469 0.086 2.91 0.181 4.37 0.284 c 4.405 0.3 8.8 0.62 13.2 0.984 A 841.9 841.9 0 0 1 299.932 -784.6 c 2.061 0.793 4.12 1.585 6.19 2.4 c 4.175 1.61 8.315 3.293 12.446 4.993 q 15.309 6.24 30.333 13.118 l -91.961 190.994 a 22.714 22.714 0 0 0 5.246 26.632 a 22.349 22.349 0 0 0 5.349 3.6 c 5.911 2.846 13.752 2.6 20.985 -0.662 a 38.549 38.549 0 1 1 -21.492 44.635 c -1.957 -7.69 -6.657 -13.971 -12.568 -16.817 a 22.372 22.372 0 0 0 -6.148 -1.939 a 22.708 22.708 0 0 0 -24.081 12.49 L 119.907 -288.482 a 308.9 308.9 0 0 0 -113.857 -24.055 c -1.361 -0.034 -2.729 -0.048 -4.08 -0.055 l -2.658 -0.015 c -3.38 0.015 -6.77 0.093 -10.131 0.205 A 308.721 308.721 0 0 0 -119.907 -288.455 L -209.1 -473.642 a 7.645 7.645 0 0 1 6.411 -10.964 a 71.13 71.13 0 1 0 -23.886 -139.181 a 73.715 73.715 0 0 0 -10.414 4.065 a 70.73 70.73 0 0 0 -22.556 17.064 a 7.627 7.627 0 0 1 -12.577 -1.816 Z" />
...
<svg>

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

Pressing the dart key will alter the sprite's direction in a 2D game

Recently, I've been working on a Dart game where the user controls a space ship sprite using the W, A, S, and D keys. Pressing these keys will move the sprite up, left, right, and down respectively. Additionally, pressing the Space bar will launch a p ...

Utilize JQuery to transfer a cell that currently resides in one row to a new row

I need to relocate a cell within a table from one row to another. The table currently has only one row with four cells, and I specifically want to move the third cell to a new row. Here is the existing markup: <table class="sbtable"> <tbody> ...

The hover effect on the menu button is not covering the entire button when the screen is resized

It appears that I am encountering a problem with the hover functionality. When my screen is at full size, hovering over a menu option causes the entire background color to change. However, upon resizing the screen, only a part of the background color chang ...

confirm chosen option html php

Is there a way to validate the select tag so that an alert appears when the user tries to submit without selecting a session? Below is the HTML and PHP code I have been using, any help would be appreciated. <select name="ses"> <o ...

Find common connections on Facebook using an app PRIOR to downloading it

Is there a way to programmatically find mutual friends between myself and an application or page? For instance, in the scenario shown below: In the image above, it's evident that prior to installing the Causes App (1) I can observe that myself and t ...

Discovering the data from every input field using jQuery

So, I've created a program that starts with one input field. By pressing the plus button, it adds new input fields with different IDs. When I press calculate, I want to save all the input field values into an array. I attempted using a for loop with . ...

Update the class name by utilizing template literals

I'm currently in the process of mastering template literals as I have a project where I need to utilize them. However, I seem to be encountering an issue that I can't quite figure out. Here is the code that is currently working: const classes = ...

What is the proper way to link an image in a nuxt project?

I am working on a modal in the app.html file of my Nuxt project that prompts Internet Explorer users to switch to another browser. The modal includes links to three different browsers for download. Although the modal is displaying correctly, I keep encount ...

CSS: Including an item in a list causes the <div> to expand upwards on the page instead of stretching downwards

Iā€™m currently facing an issue with my list where, upon reaching a certain number of items (in this case 5), the list starts moving up the page instead of extending downwards as expected. I suspect that this problem is related to my use of CSS grid-templa ...

Nesting CSS classes allows for more specific targeting of

I am a bit rusty on CSS, it's been about 5-7 years since I last worked with it. Could someone help me come up with a solution to my problem? Here's the ideal design I have in mind: table.ctable { class:collapsible collapsed; } I know this syn ...

Error: Attempting to append a child to a non-existent property

I am currently learning Java Script and this is the code I have been working on. <!doctype html> <html> <head> <style> div {position:absolute; width:500px; height:500px} img {position:absolute} ...

Fluidly move through spaces where subsequent elements align to the top level

In the black container, there is an {overflow:hidden;} CSS property applied The yellow blocks are ordered in code according to the numbers and have {float:left;} I am aiming for the 5th element to align with the element above it: However, currently this ...

How can I effectively structure a request for a list of issuu documents on Issuu?

I am attempting to utilize issuu.documents.list in order to display a list of documents from issuu. Initially, it was working fine without any issues. However, as soon as I added two additional parameters - startIndex and pageSize - the functionality cease ...

What are the steps to create a reliable menu?

Looking to add a fixed menu to my website that stays at the top even when scrolling down the page. For an example, check out iplex.co.in for a demonstration. ...

Is there a way for me to input items into a database by sorting them according to their ranking and then clicking a

I have a website designed for my NASCAR-loving family. The page I focus on the most is the Roster page. In this page, I categorize drivers into five ranks (A, B, C, D, and E) based on data from a JSON file provided by NASCAR. Each driver is accompanied by ...

Using PHP to create an HTML table that can have variable rows and columns, with the data in each row depending on

My latest project involves an assessment system that evaluates each student's performance in every lesson. I have a form set up to generate a table with the following headers: Student name Student ID Lesson title Lesson ID Lesson grade In order to ...

Information backed by the HTML5 Local Storage feature

Is it possible to use a Local Storage object to store another Local Storage object? Thank you in advance. ...

Java code for replacing text with quotes

When I receive HTML code from an internet service, it includes the following: <div style="text"></div> I want to replace 'style="text"' with 'new="aaa"'. However, my current attempt at using the replace function is not wor ...

Using jQuery to Capture Datepicker Input and Assigning to PHP Variable

I need help figuring out how to save a jQuery datepicker value in a php date formatted variable. My goal is to have: input field named "reviewdate" = 03/02/2015 input field named "reviewmonth" = 3 Both values should be stored in a mysql database. I am ...

Steps to create a translating floating chat button on your website

Hello there! I am attempting to replicate the style of a Floating Website Chat Button. When a user clicks on the large button, I want it to disappear and transform into a chat box. Something similar to this example: https://codepen.io/neilkalman/pen/VPJpaW ...