I’ve actually successfully created this several days ago, and had made a previous post asking about this… but, although my version works, it’s done using some cheats/workarounds, and I’d love to do a more solid/proper version of it.
At it’s simplest form, I just want to have a (‘stage’) image with several smaller images overtop of it (z-axis), which will be animated (position/rotation)… AND the ‘stage’ image and it’s smaller child images (and their animations) would properly scale together when put in a responsive Boostrap structure.
The way I’m doing it has one annoying flaw, in that the child images don’t scale when the larger image does, so I had to cheat that via the smaller image’s column size, and padding/positioning offsets.
As a result, even the positioning of the child elements is a matter of guesswork/compromise, partially since I ended up having to use percentages.
I tried again today, completely rebuilding it from scratch… and this time around, the scaling is happening nicely, but the positioning is the issue. Despite the proper scaling, using pixel values results in the children pushing off to the right as the screen gets smaller (…the offset is not scaling with the image). And when I tried percentage values, it did the same (which was a surprise, as I thought that would always result in the same relative location).
I looked into Canvas, and was pleased to see that all the placement of the child objects are done relative to a fixed size ‘stage’ image… so I wasn’t having to manually adjust their size/placement for each screensize version of the ‘stage’ image.
So, the question is… Is there a way to do this using vanilla CSS… having smaller (child) objects on top of a ‘stage’ object, animating, yet all the child objects (and their animations) scaling down together when in a responsive structure? Or, do I need to have the ‘stage’ a Canvas item?
Here’s a codepen demo to help illustrate what I mean. This is more just to show you the visual layout I’m describing. The code itself would not necessarily be the same in the real version. Again, just a large ‘stage’ image, with several smaller images overtop, which would be animated (position and rotation drifting)… and, most importantly, everything (children images AND animation) would scale down properly with the stage image.