Skip to content
Advertisement

How to align HTML elements(icons) along the curve using CSS, JS

Good day fellas,

Can’t figure out a way to align those png icons along the curve. I’m looking for CSS or(and) Javascript solutions for this. Any ideas on how to do it?

icons aligned along the curve

HTML

JavaScript

CSS

JavaScript

And depending on the screen size the SVG height will be changed like this:

JavaScript

Advertisement

Answer

If the svg is shown in its entirety the whole layout can be done relative to that – the % positions of each icon being calculated in the CSS.

This snippet has the aspect ratio of the svg and the positions of each icon put in from being measured. CSS calc then produces the % distances. The sizes taper down across the width and the distance between icons is constant.

The measurements in this snippet are not absolutely accurate, just put in for this demo. You’ll probably want to do them for yourself.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement