I am working on an HTML/CSS/JavaScript application and I have a functionality where a user clicks several options of images (of different sizes) and when they click “Go!” the application will use JavaScript to overlay the images on top of one another (in an order so that the largest image goes on bottom and so on). I’ve looked around and most of the websites I looked at suggested using CSS position:absolute but I was wondering if there is another way to do this using JavaScript so it is more interactive.
Any suggestions? I am a beginner in JavaScript so sorry for asking a junior question.
You can use JavaScript to manipulate the position of the images. Assign an id to each image and use JavaScript
getElementByIdto change the positions.So something like:
And then your JavaScript:
You can do this with multiple images, just assign each image div a unique id.